@zephyr3d/scene 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +46 -0
  2. package/dist/animation/animation.js +28 -28
  3. package/dist/animation/skeleton.js +14 -14
  4. package/dist/animation/usertrack.js +9 -9
  5. package/dist/app.js +31 -31
  6. package/dist/asset/assetmanager.js +50 -50
  7. package/dist/asset/builtin.js +157 -157
  8. package/dist/asset/loaders/dds/dds_loader.js +11 -11
  9. package/dist/asset/loaders/gltf/gltf_loader.js +10 -10
  10. package/dist/asset/loaders/hdr/hdr.js +5 -5
  11. package/dist/asset/loaders/image/tga_Loader.js +3 -3
  12. package/dist/asset/loaders/image/webimage_loader.js +3 -3
  13. package/dist/asset/loaders/loader.js +19 -19
  14. package/dist/asset/model.js +57 -57
  15. package/dist/blitter/blitter.js +35 -35
  16. package/dist/blitter/box.js +24 -24
  17. package/dist/blitter/depthlimitedgaussion.js +3 -3
  18. package/dist/blitter/gaussianblur.js +21 -21
  19. package/dist/camera/camera.js +68 -68
  20. package/dist/index.d.ts +2 -0
  21. package/dist/material/grassmaterial.js +17 -17
  22. package/dist/material/lambert.js +3 -3
  23. package/dist/material/lightmodel.js +362 -362
  24. package/dist/material/material.js +50 -50
  25. package/dist/material/meshmaterial.js +48 -48
  26. package/dist/material/unlit.js +3 -3
  27. package/dist/posteffect/bloom.js +5 -5
  28. package/dist/posteffect/compositor.js +16 -16
  29. package/dist/posteffect/fxaa.js +5 -5
  30. package/dist/posteffect/grayscale.js +5 -5
  31. package/dist/posteffect/posteffect.js +42 -42
  32. package/dist/posteffect/sao.js +5 -5
  33. package/dist/posteffect/tonemap.js +5 -5
  34. package/dist/posteffect/water.js +6 -6
  35. package/dist/render/cull_visitor.js +12 -12
  36. package/dist/render/depth_pass.js +8 -8
  37. package/dist/render/envlight.js +104 -104
  38. package/dist/render/render_queue.js +33 -33
  39. package/dist/render/renderpass.js +18 -18
  40. package/dist/render/renderscheme.js +14 -14
  41. package/dist/render/scatteringlut.js +3 -3
  42. package/dist/render/sky.js +38 -38
  43. package/dist/render/temporalcache.js +4 -4
  44. package/dist/render/watermesh.js +5 -5
  45. package/dist/scene/graph_node.js +25 -25
  46. package/dist/scene/octree.js +191 -191
  47. package/dist/scene/scene.js +37 -37
  48. package/dist/scene/terrain/grass.js +27 -27
  49. package/dist/scene/terrain/quadtree.js +45 -45
  50. package/dist/shaders/framework.js +161 -161
  51. package/dist/shaders/lighting.js +7 -7
  52. package/dist/shaders/noise.js +43 -43
  53. package/dist/shadow/shadowmapper.js +76 -76
  54. package/dist/shadow/ssm.js +34 -34
  55. package/dist/utility/bounding_volume.js +30 -27
  56. package/dist/utility/bounding_volume.js.map +1 -1
  57. package/dist/utility/shprojection.js +14 -14
  58. package/package.json +70 -70
  59. package/dist/material/mixins/texture.js +0 -110
  60. package/dist/material/mixins/texture.js.map +0 -1
@@ -15,9 +15,9 @@ import '../render/sky.js';
15
15
  import '../render/clipmap.js';
16
16
  import '../render/watermesh.js';
17
17
 
18
- /**
19
- * The camera node class
20
- * @public
18
+ /**
19
+ * The camera node class
20
+ * @public
21
21
  */ class Camera extends SceneNode {
22
22
  /** @internal */ _projMatrix;
23
23
  /** @internal */ _viewMatrix;
@@ -35,10 +35,10 @@ import '../render/watermesh.js';
35
35
  /** @internal */ _scissor;
36
36
  /** @internal */ _clearColor;
37
37
  /** @internal */ _clipMask;
38
- /**
39
- * Creates a new camera node
40
- * @param scene - The scene that the camera belongs to
41
- * @param projectionMatrix - Projection matrix for this camera
38
+ /**
39
+ * Creates a new camera node
40
+ * @param scene - The scene that the camera belongs to
41
+ * @param projectionMatrix - Projection matrix for this camera
42
42
  */ constructor(scene, projectionMatrix){
43
43
  super(scene);
44
44
  this._projMatrix = projectionMatrix || Matrix4x4.identity();
@@ -64,11 +64,11 @@ import '../render/watermesh.js';
64
64
  this._clipPlane = plane;
65
65
  this._invalidate(false);
66
66
  }
67
- /**
68
- * Sample count for MSAA
69
- *
70
- * @remarks
71
- * If greater than one, force the scene to be rendered using multisampled framebuffer
67
+ /**
68
+ * Sample count for MSAA
69
+ *
70
+ * @remarks
71
+ * If greater than one, force the scene to be rendered using multisampled framebuffer
72
72
  */ get sampleCount() {
73
73
  return this._sampleCount;
74
74
  }
@@ -117,11 +117,11 @@ import '../render/watermesh.js';
117
117
  this._clearColor.set(val);
118
118
  }
119
119
  }
120
- /**
121
- * Handle input events
122
- * @param ev - input event object
123
- * @param type - event type, default to ev.type
124
- * @returns Boolean value indicates whether the event was handled.
120
+ /**
121
+ * Handle input events
122
+ * @param ev - input event object
123
+ * @param type - event type, default to ev.type
124
+ * @returns Boolean value indicates whether the event was handled.
125
125
  */ handleEvent(ev, type) {
126
126
  let handled = false;
127
127
  if (this._controller) {
@@ -145,61 +145,61 @@ import '../render/watermesh.js';
145
145
  }
146
146
  return handled;
147
147
  }
148
- /**
149
- * Place the camera by specifying the camera position and the target point
150
- * @param eye - The camera position
151
- * @param target - The target point to look at
152
- * @param up - The up vector
153
- * @returns self
148
+ /**
149
+ * Place the camera by specifying the camera position and the target point
150
+ * @param eye - The camera position
151
+ * @param target - The target point to look at
152
+ * @param up - The up vector
153
+ * @returns self
154
154
  */ lookAt(eye, target, up) {
155
155
  return this.setLocalTransform(Matrix4x4.lookAt(eye, target, up));
156
156
  }
157
- /**
158
- * Place the camera to look at a given cube face at a given camera position
159
- * @param face - The cube face to look at
160
- * @param position - The camera position
161
- * @returns self
157
+ /**
158
+ * Place the camera to look at a given cube face at a given camera position
159
+ * @param face - The cube face to look at
160
+ * @param position - The camera position
161
+ * @returns self
162
162
  */ lookAtCubeFace(face, position) {
163
163
  return this.setLocalTransform(Matrix4x4.lookAtCubeFace(face, position ?? this.position));
164
164
  }
165
- /**
166
- * Setup a perspective projection matrix for the camera
167
- * @param fovY - The vertical field of view in radians.
168
- * @param aspect - The aspect ratio
169
- * @param zNear - The near clip plane
170
- * @param zFar - The far clip plane
171
- * @returns self
165
+ /**
166
+ * Setup a perspective projection matrix for the camera
167
+ * @param fovY - The vertical field of view in radians.
168
+ * @param aspect - The aspect ratio
169
+ * @param zNear - The near clip plane
170
+ * @param zFar - The far clip plane
171
+ * @returns self
172
172
  */ setPerspective(fovY, aspect, zNear, zFar) {
173
173
  this._projMatrix.perspective(fovY, aspect, zNear, zFar);
174
174
  this._invalidate(true);
175
175
  return this;
176
176
  }
177
- /**
178
- * Setup a orthogonal projection matrix for the camera
179
- * @param left - Left bound of the frustum
180
- * @param right - Right bound of the frustum
181
- * @param bottom - Bottom bound of the frustum
182
- * @param top - Top bound of the frustum
183
- * @param near - Near bound of the frustum.
184
- * @param far - Far bound of the frustum.
185
- * @returns self
177
+ /**
178
+ * Setup a orthogonal projection matrix for the camera
179
+ * @param left - Left bound of the frustum
180
+ * @param right - Right bound of the frustum
181
+ * @param bottom - Bottom bound of the frustum
182
+ * @param top - Top bound of the frustum
183
+ * @param near - Near bound of the frustum.
184
+ * @param far - Far bound of the frustum.
185
+ * @returns self
186
186
  */ setOrtho(left, right, bottom, top, near, far) {
187
187
  this._projMatrix.ortho(left, right, bottom, top, near, far);
188
188
  this._invalidate(true);
189
189
  return this;
190
190
  }
191
- /**
192
- * Setup a projection matrix for the camera
193
- * @param matrix - The projection matrix
191
+ /**
192
+ * Setup a projection matrix for the camera
193
+ * @param matrix - The projection matrix
194
194
  */ setProjectionMatrix(matrix) {
195
195
  if (matrix && matrix !== this._projMatrix) {
196
196
  this._projMatrix.set(matrix);
197
197
  this._invalidate(true);
198
198
  }
199
199
  }
200
- /**
201
- * Gets the projection matrix of the camera
202
- * @returns The projection matrix
200
+ /**
201
+ * Gets the projection matrix of the camera
202
+ * @returns The projection matrix
203
203
  */ getProjectionMatrix() {
204
204
  if (this._dirty) {
205
205
  this._dirty = false;
@@ -218,11 +218,11 @@ import '../render/watermesh.js';
218
218
  rotationMatrix.setRow(2, new Vector4(zAxis.x, zAxis.y, zAxis.z, 0));
219
219
  return rotationMatrix;
220
220
  }
221
- /**
222
- * View matrix of the camera
223
- *
224
- * @remarks
225
- * Camera's view matrix will transform a point from the world space to the camera space
221
+ /**
222
+ * View matrix of the camera
223
+ *
224
+ * @remarks
225
+ * Camera's view matrix will transform a point from the world space to the camera space
226
226
  */ get viewMatrix() {
227
227
  if (this._dirty) {
228
228
  this._dirty = false;
@@ -237,11 +237,11 @@ import '../render/watermesh.js';
237
237
  }
238
238
  return this._viewProjMatrix;
239
239
  }
240
- /**
241
- * The inverse-view-projection matrix of the camera
242
- *
243
- * @remarks
244
- * The inverse-view-projection matrix transforms a point from the clip space to the camera space
240
+ /**
241
+ * The inverse-view-projection matrix of the camera
242
+ *
243
+ * @remarks
244
+ * The inverse-view-projection matrix transforms a point from the clip space to the camera space
245
245
  */ get invViewProjectionMatrix() {
246
246
  if (this._dirty) {
247
247
  this._dirty = false;
@@ -290,10 +290,10 @@ import '../render/watermesh.js';
290
290
  /** Gets the aspect ratio */ getAspect() {
291
291
  return this._projMatrix.getAspect();
292
292
  }
293
- /**
294
- * Renders a scene
295
- * @param scene - The scene to be rendered
296
- * @param compositor - Compositor instance that will be used to apply postprocess effects
293
+ /**
294
+ * Renders a scene
295
+ * @param scene - The scene to be rendered
296
+ * @param compositor - Compositor instance that will be used to apply postprocess effects
297
297
  */ render(scene, compositor, logger) {
298
298
  const device = Application.instance.device;
299
299
  device.pushDeviceStates();
@@ -303,13 +303,13 @@ import '../render/watermesh.js';
303
303
  ForwardRenderScheme.renderScene(scene, this, compositor, logger);
304
304
  device.popDeviceStates();
305
305
  }
306
- /**
307
- * Updates the controller state
306
+ /**
307
+ * Updates the controller state
308
308
  */ updateController() {
309
309
  this._controller?.update();
310
310
  }
311
- /**
312
- * Reset the controller
311
+ /**
312
+ * Reset the controller
313
313
  */ resetController() {
314
314
  this._controller?.reset();
315
315
  }
package/dist/index.d.ts CHANGED
@@ -160,6 +160,8 @@ declare class BoundingBox extends AABB implements BoundingVolume {
160
160
  * @param maxPoint - Max point of the box
161
161
  */
162
162
  constructor(minPoint: Vector3, maxPoint: Vector3);
163
+ /** {@inheritDoc BoundingVolume.behindPlane} */
164
+ behindPlane(plane: Plane): boolean;
163
165
  /** {@inheritDoc BoundingVolume.clone} */
164
166
  clone(): BoundingVolume;
165
167
  /** {@inheritDoc BoundingVolume.transform} */
@@ -11,17 +11,17 @@ import './unlit.js';
11
11
  import { PBRLightModelMR } from './lightmodel.js';
12
12
  import { Vector4, Vector2 } from '@zephyr3d/base';
13
13
 
14
- /**
15
- * The terrain material
16
- * @public
14
+ /**
15
+ * The terrain material
16
+ * @public
17
17
  */ class GrassMaterial extends Material {
18
18
  /** @internal */ _lightModel;
19
19
  /** @internal */ _terrainSize;
20
20
  /** @internal */ _normalMap;
21
21
  /** @internal */ _textureSize;
22
22
  /** @internal */ _useAlphaToCoverage;
23
- /**
24
- * Creates an instance of TerrainMaterial
23
+ /**
24
+ * Creates an instance of TerrainMaterial
25
25
  */ constructor(terrainSize, normalMap, grassTexture){
26
26
  super();
27
27
  this._lightModel = new PBRLightModelMR();
@@ -67,28 +67,28 @@ import { Vector4, Vector2 } from '@zephyr3d/base';
67
67
  set color(val) {
68
68
  this._lightModel.albedo = val;
69
69
  }
70
- /**
71
- * {@inheritDoc Material.isTransparent}
72
- * @override
70
+ /**
71
+ * {@inheritDoc Material.isTransparent}
72
+ * @override
73
73
  */ isTransparent() {
74
74
  return false;
75
75
  }
76
- /**
77
- * {@inheritDoc Material.supportLighting}
78
- * @override
76
+ /**
77
+ * {@inheritDoc Material.supportLighting}
78
+ * @override
79
79
  */ supportLighting() {
80
80
  return this._lightModel.supportLighting();
81
81
  }
82
- /**
83
- * {@inheritDoc Material.applyUniforms}
84
- * @override
82
+ /**
83
+ * {@inheritDoc Material.applyUniforms}
84
+ * @override
85
85
  */ applyUniforms(bindGroup, ctx, needUpdate) {
86
86
  super.applyUniforms(bindGroup, ctx, needUpdate);
87
87
  this._lightModel.applyUniformsIfOutdated(bindGroup, ctx);
88
88
  }
89
- /**
90
- * {@inheritDoc Material._applyUniforms}
91
- * @override
89
+ /**
90
+ * {@inheritDoc Material._applyUniforms}
91
+ * @override
92
92
  */ _applyUniforms(bindGroup, ctx) {
93
93
  bindGroup.setValue('terrainSize', this._terrainSize);
94
94
  bindGroup.setTexture('terrainNormalMap', this._normalMap);
@@ -3,9 +3,9 @@ import { mixinAlbedoColor } from './mixins/albedocolor.js';
3
3
  import { mixinVertexColor } from './mixins/vertexcolor.js';
4
4
  import { applyMaterialMixins } from './meshmaterial.js';
5
5
 
6
- /**
7
- * Lambert material
8
- * @public
6
+ /**
7
+ * Lambert material
8
+ * @public
9
9
  */ class LambertMaterial extends applyMaterialMixins(LitMaterial, mixinVertexColor, mixinAlbedoColor) {
10
10
  constructor(){
11
11
  super();