UNPKG

4.24 kBTypeScriptView Raw
1import { JSONMeta, Object3D, Object3DJSON, Object3DJSONObject } from "../core/Object3D.js";
2import { Material } from "../materials/Material.js";
3import { Color } from "../math/Color.js";
4import { Euler, EulerTuple } from "../math/Euler.js";
5import { CubeTexture } from "../textures/CubeTexture.js";
6import { Texture } from "../textures/Texture.js";
7import { Fog, FogJSON } from "./Fog.js";
8import { FogExp2, FogExp2JSON } from "./FogExp2.js";
9
10export interface SceneJSONObject extends Object3DJSONObject {
11 fog?: FogJSON | FogExp2JSON;
12
13 backgroundBlurriness?: number;
14 backgroundIntensity?: number;
15 backgroundRotation: EulerTuple;
16
17 environmentIntensity?: number;
18 environmentRotation: EulerTuple;
19}
20
21export interface SceneJSON extends Object3DJSON {
22 object: SceneJSONObject;
23}
24
25/**
26 * Scenes allow you to set up what and where is to be rendered by three.js
27 * @remarks
28 * This is where you place objects, lights and cameras.
29 * @see Example: {@link https://threejs.org/examples/#webgl_multiple_scenes_comparison | webgl multiple scenes comparison}
30 * @see {@link https://threejs.org/docs/index.html#manual/en/introduction/Creating-a-scene | Manual: Creating a scene}
31 * @see {@link https://threejs.org/docs/index.html#api/en/scenes/Scene | Official Documentation}
32 * @see {@link https://github.com/mrdoob/three.js/blob/master/src/scenes/Scene.js | Source}
33 */
34export class Scene extends Object3D {
35 /**
36 * Create a new {@link Scene} object.
37 */
38 constructor();
39
40 /**
41 * Read-only flag to check if a given object is of type {@link Scene}.
42 * @remarks This is a _constant_ value
43 * @defaultValue `true`
44 */
45 readonly isScene: true;
46
47 /**
48 * @defaultValue `Scene`
49 */
50 type: "Scene";
51
52 /**
53 * A {@link Fog | fog} instance defining the type of fog that affects everything rendered in the scene.
54 * @defaultValue `null`
55 */
56 fog: Fog | FogExp2 | null;
57
58 /**
59 * Sets the blurriness of the background. Only influences environment maps assigned to {@link THREE.Scene.background | Scene.background}.
60 * @defaultValue `0`
61 * @remarks Expects a `Float` between `0` and `1`.
62 */
63 backgroundBlurriness: number;
64
65 /**
66 * Attenuates the color of the background. Only applies to background textures.
67 * @defaultValue `1`
68 * @remarks Expects a `Float`
69 */
70 backgroundIntensity: number;
71
72 /**
73 * Forces everything in the {@link Scene} to be rendered with the defined material.
74 * @defaultValue `null`
75 */
76 overrideMaterial: Material | null;
77
78 /**
79 * Defines the background of the scene.
80 * @remarks Valid inputs are:
81 * - A {@link THREE.Color | Color} for defining a uniform colored background.
82 * - A {@link THREE.Texture | Texture} for defining a (flat) textured background.
83 * - Texture cubes ({@link THREE.CubeTexture | CubeTexture}) or equirectangular textures for defining a skybox.</li>
84 * @defaultValue `null`
85 */
86 background: Color | Texture | CubeTexture | null;
87
88 /**
89 * The rotation of the background in radians. Only influences environment maps assigned to {@link .background}.
90 * Default is `(0,0,0)`.
91 */
92 backgroundRotation: Euler;
93
94 /**
95 * Sets the environment map for all physical materials in the scene.
96 * However, it's not possible to overwrite an existing texture assigned to {@link THREE.MeshStandardMaterial.envMap | MeshStandardMaterial.envMap}.
97 * @defaultValue `null`
98 */
99 environment: Texture | null;
100
101 /**
102 * Attenuates the color of the environment. Only influences environment maps assigned to {@link Scene.environment}.
103 * @default 1
104 */
105 environmentIntensity: number;
106
107 /**
108 * The rotation of the environment map in radians. Only influences physical materials in the scene when
109 * {@link .environment} is used. Default is `(0,0,0)`.
110 */
111 environmentRotation: Euler;
112
113 /**
114 * Convert the {@link Scene} to three.js {@link https://github.com/mrdoob/three.js/wiki/JSON-Object-Scene-format-4 | JSON Object/Scene format}.
115 * @param meta Object containing metadata such as textures or images for the scene.
116 */
117 toJSON(meta?: JSONMeta): SceneJSON;
118}