<commit_before>import { BoundingSphere } from "../../Source/Cesium.js";
import { Cartesian2 } from "../../Source/Cesium.js";
import { Cartesian3 } from "../../Source/Cesium.js";
import { CesiumTerrainProvider } from "../../Source/Cesium.js";
import { Color } from "../../Source/Cesium.js";
import { defined } from "../../Source/Cesium.js";
import { Ellipsoid } from "../../Source/Cesium.js";
import { FeatureDetection } from "../../Source/Cesium.js";
import { GeographicProjection } from "../../Source/Cesium.js";
import { GeometryInstance } from "../../Source/Cesium.js";
import { HeadingPitchRoll } from "../../Source/Cesium.js";
import { JulianDate } from "../../Source/Cesium.js";
import { Math as CesiumMath } from "../../Source/Cesium.js";
import { PerspectiveFrustum } from "../../Source/Cesium.js";
import { PixelFormat } from "../../Source/Cesium.js";
import { Rectangle } from "../../Source/Cesium.js";
import { RectangleGeometry } from "../../Source/Cesium.js";
import { RequestScheduler } from "../../Source/Cesium.js";
import { RuntimeError } from "../../Source/Cesium.js";
import { TaskProcessor } from "../../Source/Cesium.js";
import { WebGLConstants } from "../../Source/Cesium.js";
import { WebMercatorProjection } from "../../Source/Cesium.js";
import { DrawCommand } from "../../Source/Cesium.js";
import { Framebuffer } from "../../Source/Cesium.js";
import { Pass } from "../../Source/Cesium.js";
import { PixelDatatype } from "../../Source/Cesium.js";
import { RenderState } from "../../Source/Cesium.js";
import { ShaderProgram } from "../../Source/Cesium.js";
import { ShaderSource } from "../../Source/Cesium.js";
import { Texture } from "../../Source/Cesium.js";
import { Camera } from "../../Source/Cesium.js";
import { DirectionalLight } from "../../Source/Cesium.js";
import { EllipsoidSurfaceAppearance } from "../../Source/Cesium.js";
import { FrameState } from "../../Source/Cesium.js";
import { Globe } from "../../Source/Cesium.js";
import { Material } from "../../Source/Cesium.js";
import { Primitive } from "../../Source/Cesium.js";
import { PrimitiveCollection } from "../../Source/Cesium.js";
import { Scene } from "../../Source/Cesium.js";
import { SceneTransforms } from "../../Source/Cesium.js";
import { ScreenSpaceCameraController } from "../../Source/Cesium.js";
import { SunLight } from "../../Source/Cesium.js";
import { TweenCollection } from "../../Source/Cesium.js";
import { Sun } from "../../Source/Cesium.js";
import { GroundPrimitive } from "../../Source/Cesium.js";
import { PerInstanceColorAppearance } from "../../Source/Cesium.js";
import { ColorGeometryInstanceAttribute } from "../../Source/Cesium.js";
import createCanvas from "../createCanvas.js";
import createScene from "../createScene.js";
import pollToPromise from "../pollToPromise.js";
import render from "../render.js";

describe(
  "Scene/Scene",
  function () {
    let scene;
    let simpleShaderProgram;
    let simpleRenderState;

    beforeAll(function () {
      scene = createScene();
      simpleShaderProgram = ShaderProgram.fromCache({
        context: scene.context,
        vertexShaderSource: new ShaderSource({
          sources: ["void main() { gl_Position = vec4(1.0); }"],
        }),
        fragmentShaderSource: new ShaderSource({
          sources: ["void main() { gl_FragColor = vec4(1.0); }"],
        }),
      });
      simpleRenderState = new RenderState();

      return GroundPrimitive.initializeTerrainHeights();
    });

    afterEach(function () {
      scene.backgroundColor = new Color(0.0, 0.0, 0.0, 0.0);
      scene.debugCommandFilter = undefined;
      scene.postProcessStages.fxaa.enabled = false;
      scene.primitives.removeAll();
      scene.morphTo3D(0.0);

      const camera = scene.camera;
      camera.frustum = new PerspectiveFrustum();
      camera.frustum.aspectRatio =
        scene.drawingBufferWidth / scene.drawingBufferHeight;
      camera.frustum.fov = CesiumMath.toRadians(60.0);
    });

    afterAll(function () {
      scene.destroyForSpecs();
    });

    function createRectangle(rectangle, height) {
      return new Primitive({
        geometryInstances: new GeometryInstance({
          geometry: new RectangleGeometry({
            rectangle: rectangle,
            vertexFormat: EllipsoidSurfaceAppearance.VERTEX_FORMAT,
            height: height,
          }),
        }),
        appearance: new EllipsoidSurfaceAppearance({
          aboveGround: false,
        }),
        asynchronous: false,
      });
    }

    it("constructor has expected defaults", function () {
      expect(scene.canvas).toBeInstanceOf(HTMLCanvasElement);
      expect(scene.primitives).toBeInstanceOf(PrimitiveCollection);
      expect(scene.camera).toBeInstanceOf(Camera);
      expect(scene.screenSpaceCameraController).toBeInstanceOf(
        ScreenSpaceCameraController
      );
      expect(scene.mapProjection).toBeInstanceOf(GeographicProjection);
      expect(scene.frameState).toBeInstanceOf(FrameState);
      expect(scene.tweens).toBeInstanceOf(TweenCollection);

      const contextAttributes = scene.context._gl.getContextAttributes();
      // Do not check depth and antialias since they are requests not requirements
      expect(contextAttributes.alpha).toEqual(false);
      expect(contextAttributes.stencil).toEqual(true);
      expect(contextAttributes.premultipliedAlpha).toEqual(true);
      expect(contextAttributes.preserveDrawingBuffer).toEqual(false);
      expect(scene._depthPlane._ellipsoidOffset).toEqual(0);
    });

    it("constructor default OIT to disabled if running on iPad or iOS", function () {
      spyOn(FeatureDetection, "isIPadOrIOS").and.returnValue(true);
      const scene = createScene();
      expect(scene.orderIndependentTranslucency).toBe(false);
    });

    it("constructor sets options", function () {
      const webglOptions = {
        alpha: true,
        depth: true, //TODO Change to false when https://bugzilla.mozilla.org/show_bug.cgi?id=745912 is fixed.
        stencil: true,
        antialias: false,
        premultipliedAlpha: true, // Workaround IE 11.0.8, which does not honor false.
        preserveDrawingBuffer: true,
      };
      const mapProjection = new WebMercatorProjection();<commit_msg>Remove problematic temporary spec<commit_after>import { BoundingSphere } from "../../Source/Cesium.js";
import { Cartesian2 } from "../../Source/Cesium.js";
import { Cartesian3 } from "../../Source/Cesium.js";
import { CesiumTerrainProvider } from "../../Source/Cesium.js";
import { Color } from "../../Source/Cesium.js";
import { defined } from "../../Source/Cesium.js";
import { Ellipsoid } from "../../Source/Cesium.js";
import { FeatureDetection } from "../../Source/Cesium.js";
import { GeographicProjection } from "../../Source/Cesium.js";
import { GeometryInstance } from "../../Source/Cesium.js";
import { HeadingPitchRoll } from "../../Source/Cesium.js";
import { JulianDate } from "../../Source/Cesium.js";
import { Math as CesiumMath } from "../../Source/Cesium.js";
import { PerspectiveFrustum } from "../../Source/Cesium.js";
import { PixelFormat } from "../../Source/Cesium.js";
import { Rectangle } from "../../Source/Cesium.js";
import { RectangleGeometry } from "../../Source/Cesium.js";
import { RequestScheduler } from "../../Source/Cesium.js";
import { RuntimeError } from "../../Source/Cesium.js";
import { TaskProcessor } from "../../Source/Cesium.js";
import { WebGLConstants } from "../../Source/Cesium.js";
import { WebMercatorProjection } from "../../Source/Cesium.js";
import { DrawCommand } from "../../Source/Cesium.js";
import { Framebuffer } from "../../Source/Cesium.js";
import { Pass } from "../../Source/Cesium.js";
import { PixelDatatype } from "../../Source/Cesium.js";
import { RenderState } from "../../Source/Cesium.js";
import { ShaderProgram } from "../../Source/Cesium.js";
import { ShaderSource } from "../../Source/Cesium.js";
import { Texture } from "../../Source/Cesium.js";
import { Camera } from "../../Source/Cesium.js";
import { DirectionalLight } from "../../Source/Cesium.js";
import { EllipsoidSurfaceAppearance } from "../../Source/Cesium.js";
import { FrameState } from "../../Source/Cesium.js";
import { Globe } from "../../Source/Cesium.js";
import { Material } from "../../Source/Cesium.js";
import { Primitive } from "../../Source/Cesium.js";
import { PrimitiveCollection } from "../../Source/Cesium.js";
import { Scene } from "../../Source/Cesium.js";
import { SceneTransforms } from "../../Source/Cesium.js";
import { ScreenSpaceCameraController } from "../../Source/Cesium.js";
import { SunLight } from "../../Source/Cesium.js";
import { TweenCollection } from "../../Source/Cesium.js";
import { Sun } from "../../Source/Cesium.js";
import { GroundPrimitive } from "../../Source/Cesium.js";
import { PerInstanceColorAppearance } from "../../Source/Cesium.js";
import { ColorGeometryInstanceAttribute } from "../../Source/Cesium.js";
import createCanvas from "../createCanvas.js";
import createScene from "../createScene.js";
import pollToPromise from "../pollToPromise.js";
import render from "../render.js";

describe(
  "Scene/Scene",
  function () {
    let scene;
    let simpleShaderProgram;
    let simpleRenderState;

    beforeAll(function () {
      scene = createScene();
      simpleShaderProgram = ShaderProgram.fromCache({
        context: scene.context,
        vertexShaderSource: new ShaderSource({
          sources: ["void main() { gl_Position = vec4(1.0); }"],
        }),
        fragmentShaderSource: new ShaderSource({
          sources: ["void main() { gl_FragColor = vec4(1.0); }"],
        }),
      });
      simpleRenderState = new RenderState();

      return GroundPrimitive.initializeTerrainHeights();
    });

    afterEach(function () {
      scene.backgroundColor = new Color(0.0, 0.0, 0.0, 0.0);
      scene.debugCommandFilter = undefined;
      scene.postProcessStages.fxaa.enabled = false;
      scene.primitives.removeAll();
      scene.morphTo3D(0.0);

      const camera = scene.camera;
      camera.frustum = new PerspectiveFrustum();
      camera.frustum.aspectRatio =
        scene.drawingBufferWidth / scene.drawingBufferHeight;
      camera.frustum.fov = CesiumMath.toRadians(60.0);
    });

    afterAll(function () {
      scene.destroyForSpecs();
    });

    function createRectangle(rectangle, height) {
      return new Primitive({
        geometryInstances: new GeometryInstance({
          geometry: new RectangleGeometry({
            rectangle: rectangle,
            vertexFormat: EllipsoidSurfaceAppearance.VERTEX_FORMAT,
            height: height,
          }),
        }),
        appearance: new EllipsoidSurfaceAppearance({
          aboveGround: false,
        }),
        asynchronous: false,
      });
    }

    it("constructor has expected defaults", function () {
      expect(scene.canvas).toBeInstanceOf(HTMLCanvasElement);
      expect(scene.primitives).toBeInstanceOf(PrimitiveCollection);
      expect(scene.camera).toBeInstanceOf(Camera);
      expect(scene.screenSpaceCameraController).toBeInstanceOf(
        ScreenSpaceCameraController
      );
      expect(scene.mapProjection).toBeInstanceOf(GeographicProjection);
      expect(scene.frameState).toBeInstanceOf(FrameState);
      expect(scene.tweens).toBeInstanceOf(TweenCollection);

      const contextAttributes = scene.context._gl.getContextAttributes();
      // Do not check depth and antialias since they are requests not requirements
      expect(contextAttributes.alpha).toEqual(false);
      expect(contextAttributes.stencil).toEqual(true);
      expect(contextAttributes.premultipliedAlpha).toEqual(true);
      expect(contextAttributes.preserveDrawingBuffer).toEqual(false);
      expect(scene._depthPlane._ellipsoidOffset).toEqual(0);
    });

    it("constructor sets options", function () {
      const webglOptions = {
        alpha: true,
        depth: true, //TODO Change to false when https://bugzilla.mozilla.org/show_bug.cgi?id=745912 is fixed.
        stencil: true,
        antialias: false,
        premultipliedAlpha: true, // Workaround IE 11.0.8, which does not honor false.
        preserveDrawingBuffer: true,
      };
      const mapProjection = new WebMercatorProjection();
{'fraction_non_alphanumeric': 0.1632603008502289, 'fraction_numerical': 0.00539568345323741, 'mean_word_length': 3.03862660944206, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4003891', 'n_tokens_mistral': 3520, 'n_tokens_neox': 3476, 'n_words': 750}