@zephyr3d/scene 0.5.0 → 0.6.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.
- package/README.md +1 -1
- package/dist/animation/animationset.js +37 -37
- package/dist/animation/morphtrack.js +7 -5
- package/dist/animation/morphtrack.js.map +1 -1
- package/dist/animation/skeleton.js +11 -9
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/asset/assetmanager.js +2 -2
- package/dist/asset/loaders/gltf/gltf_loader.js +7 -3
- package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
- package/dist/asset/loaders/image/webimage_loader.js +16 -0
- package/dist/asset/loaders/image/webimage_loader.js.map +1 -1
- package/dist/asset/model.js +3 -9
- package/dist/asset/model.js.map +1 -1
- package/dist/blitter/bilateralblur.js +222 -0
- package/dist/{render/temporalcache.js.map → blitter/bilateralblur.js.map} +1 -1
- package/dist/blitter/blitter.js +7 -1
- package/dist/blitter/blitter.js.map +1 -1
- package/dist/blitter/depthlimitedgaussion.js +96 -39
- package/dist/blitter/depthlimitedgaussion.js.map +1 -1
- package/dist/blitter/gaussianblur.js +21 -21
- package/dist/camera/camera.js +142 -1
- package/dist/camera/camera.js.map +1 -1
- package/dist/index.d.ts +1178 -745
- package/dist/index.js +11 -6
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +9 -3
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/lambert.js +6 -2
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +3 -1
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +73 -33
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/albedocolor.js +5 -4
- package/dist/material/mixins/albedocolor.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +17 -7
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +5 -5
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +13 -4
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +13 -4
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +27 -15
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/pbrmr.js +14 -3
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js +14 -3
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/shader/helper.js +36 -21
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/posteffect/bloom.js +1 -10
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/compositor.js +43 -24
- package/dist/posteffect/compositor.js.map +1 -1
- package/dist/posteffect/fxaa.js +3 -11
- package/dist/posteffect/fxaa.js.map +1 -1
- package/dist/posteffect/grayscale.js +3 -11
- package/dist/posteffect/grayscale.js.map +1 -1
- package/dist/posteffect/posteffect.js +4 -0
- package/dist/posteffect/posteffect.js.map +1 -1
- package/dist/posteffect/sao.js +44 -24
- package/dist/posteffect/sao.js.map +1 -1
- package/dist/posteffect/ssr.js +536 -0
- package/dist/{material/lit.js.map → posteffect/ssr.js.map} +1 -1
- package/dist/posteffect/tonemap.js +3 -11
- package/dist/posteffect/tonemap.js.map +1 -1
- package/dist/posteffect/water.js +305 -337
- package/dist/posteffect/water.js.map +1 -1
- package/dist/render/abuffer_oit.js +2 -2
- package/dist/render/clipmap.js +16 -19
- package/dist/render/clipmap.js.map +1 -1
- package/dist/render/cull_visitor.js +5 -3
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/depthpass.js +17 -1
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable_mixin.js +25 -19
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/envlight.js +4 -2
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fft_wavegenerator.js +989 -0
- package/dist/{shaders/framework.js.map → render/fft_wavegenerator.js.map} +1 -1
- package/dist/render/gerstner_wavegenerator.js +265 -0
- package/dist/{material/standard.js.map → render/gerstner_wavegenerator.js.map} +1 -1
- package/dist/render/globalbindgroup_allocator.js +2 -1
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/hzb.js +273 -0
- package/dist/{material/terrainlightmodel.js.map → render/hzb.js.map} +1 -1
- package/dist/render/lightpass.js +35 -3
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/objectcolorpass.js +2 -1
- package/dist/render/objectcolorpass.js.map +1 -1
- package/dist/render/render_queue.js +72 -52
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderbundle_wrapper.js +79 -0
- package/dist/render/renderbundle_wrapper.js.map +1 -1
- package/dist/render/renderer.js +75 -36
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/renderpass.js +16 -13
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/shadowmap_pass.js +6 -0
- package/dist/render/shadowmap_pass.js.map +1 -1
- package/dist/render/sky.js +12 -13
- package/dist/render/sky.js.map +1 -1
- package/dist/render/watermesh.js +94 -828
- package/dist/render/watermesh.js.map +1 -1
- package/dist/render/wavegenerator.js +8 -0
- package/dist/render/wavegenerator.js.map +1 -0
- package/dist/scene/batchgroup.js +60 -14
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +2 -2
- package/dist/scene/graph_node.js +0 -5
- package/dist/scene/graph_node.js.map +1 -1
- package/dist/scene/light.js +5 -5
- package/dist/scene/mesh.js +34 -18
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/octree.js +5 -2
- package/dist/scene/octree.js.map +1 -1
- package/dist/scene/raycast_visitor.js +4 -2
- package/dist/scene/raycast_visitor.js.map +1 -1
- package/dist/scene/scene.js +1 -1
- package/dist/scene/scene_node.js +9 -5
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/terrain/grass.js +3 -4
- package/dist/scene/terrain/grass.js.map +1 -1
- package/dist/scene/terrain/heightfield.js +135 -53
- package/dist/scene/terrain/heightfield.js.map +1 -1
- package/dist/scene/terrain/patch.js +3 -4
- package/dist/scene/terrain/patch.js.map +1 -1
- package/dist/scene/terrain/terrain.js +1 -1
- package/dist/scene/xform.js +7 -9
- package/dist/scene/xform.js.map +1 -1
- package/dist/shaders/misc.js +10 -1
- package/dist/shaders/misc.js.map +1 -1
- package/dist/shaders/noise.js +81 -16
- package/dist/shaders/noise.js.map +1 -1
- package/dist/shaders/shadow.js +1 -9
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shaders/ssr.js +442 -0
- package/dist/{material/terrainmat.js.map → shaders/ssr.js.map} +1 -1
- package/dist/shaders/water.js +377 -250
- package/dist/shaders/water.js.map +1 -1
- package/dist/shadow/shadowmapper.js +11 -11
- package/dist/shapes/cylinder.js +6 -5
- package/dist/shapes/cylinder.js.map +1 -1
- package/dist/utility/bounding_volume.js +1 -53
- package/dist/utility/bounding_volume.js.map +1 -1
- package/dist/utility/misc.js +93 -0
- package/dist/utility/misc.js.map +1 -0
- package/dist/utility/shprojection.js +2 -7
- package/dist/utility/shprojection.js.map +1 -1
- package/dist/utility/textures/ggxlut.js +213 -0
- package/dist/utility/textures/ggxlut.js.map +1 -0
- package/dist/utility/textures/gradientnoise.js +61 -0
- package/dist/utility/textures/gradientnoise.js.map +1 -0
- package/dist/utility/textures/randomnoise.js +41 -0
- package/dist/utility/textures/randomnoise.js.map +1 -0
- package/dist/values.js +8 -1
- package/dist/values.js.map +1 -1
- package/package.json +4 -8
- package/dist/animation/usertrack.js +0 -47
- package/dist/animation/usertrack.js.map +0 -1
- package/dist/material/grassmat.js +0 -127
- package/dist/material/grassmat.js.map +0 -1
- package/dist/material/lightmodel.js +0 -2074
- package/dist/material/lightmodel.js.map +0 -1
- package/dist/material/lit.js +0 -578
- package/dist/material/mixins/pbr/metallicroughness.js +0 -126
- package/dist/material/mixins/pbr/metallicroughness.js.map +0 -1
- package/dist/material/mixins/pbr/specularglossness.js +0 -104
- package/dist/material/mixins/pbr/specularglossness.js.map +0 -1
- package/dist/material/pbr.js +0 -27
- package/dist/material/pbr.js.map +0 -1
- package/dist/material/standard.js +0 -282
- package/dist/material/terrainlightmodel.js +0 -259
- package/dist/material/terrainmat.js +0 -357
- package/dist/render/depth_pass.js +0 -47
- package/dist/render/depth_pass.js.map +0 -1
- package/dist/render/forward.js +0 -186
- package/dist/render/forward.js.map +0 -1
- package/dist/render/forward_pass.js +0 -137
- package/dist/render/forward_pass.js.map +0 -1
- package/dist/render/helper.js +0 -38
- package/dist/render/helper.js.map +0 -1
- package/dist/render/objectpool.js +0 -295
- package/dist/render/objectpool.js.map +0 -1
- package/dist/render/renderscheme.js +0 -61
- package/dist/render/renderscheme.js.map +0 -1
- package/dist/render/temporalcache.js +0 -222
- package/dist/scene/model.js +0 -111
- package/dist/scene/model.js.map +0 -1
- package/dist/scene/octree_update_visitor.js +0 -20
- package/dist/scene/octree_update_visitor.js.map +0 -1
- package/dist/shaders/builtins.js +0 -110
- package/dist/shaders/builtins.js.map +0 -1
- package/dist/shaders/framework.js +0 -723
- package/dist/shaders/lighting.js +0 -335
- package/dist/shaders/lighting.js.map +0 -1
- package/dist/utility/sheenlut.js +0 -196
- package/dist/utility/sheenlut.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watermesh.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"watermesh.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wavegenerator.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
package/dist/scene/batchgroup.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { GraphNode } from './graph_node.js';
|
|
2
|
-
import '@zephyr3d/base';
|
|
2
|
+
import { Matrix4x4 } from '@zephyr3d/base';
|
|
3
3
|
import './octree.js';
|
|
4
|
+
import '../values.js';
|
|
4
5
|
import '../app.js';
|
|
5
6
|
import { InstanceBindGroupAllocator, RenderQueue } from '../render/render_queue.js';
|
|
6
7
|
import '../material/shader/helper.js';
|
|
@@ -8,7 +9,6 @@ import '../render/renderer.js';
|
|
|
8
9
|
import '../render/sky.js';
|
|
9
10
|
import '../render/clipmap.js';
|
|
10
11
|
import '@zephyr3d/device';
|
|
11
|
-
import '../render/watermesh.js';
|
|
12
12
|
import '../material/lambert.js';
|
|
13
13
|
import '../material/blinn.js';
|
|
14
14
|
import '../material/unlit.js';
|
|
@@ -17,7 +17,9 @@ import '../material/grassmaterial.js';
|
|
|
17
17
|
import '../material/terrainmaterial.js';
|
|
18
18
|
import '../material/pbrmr.js';
|
|
19
19
|
import '../material/pbrsg.js';
|
|
20
|
+
import { BoundingBox } from '../utility/bounding_volume.js';
|
|
20
21
|
|
|
22
|
+
const tmpMatrix = new Matrix4x4();
|
|
21
23
|
/**
|
|
22
24
|
* Batch group node
|
|
23
25
|
* @public
|
|
@@ -25,32 +27,44 @@ import '../material/pbrsg.js';
|
|
|
25
27
|
_renderQueueMap;
|
|
26
28
|
_bindGroupAllocator;
|
|
27
29
|
_changeTag;
|
|
30
|
+
_staticBV;
|
|
28
31
|
/**
|
|
29
32
|
* Creates an instance of mesh node
|
|
30
33
|
* @param scene - The scene to which the mesh node belongs
|
|
31
34
|
*/ constructor(scene){
|
|
32
35
|
super(scene);
|
|
33
|
-
this._renderQueueMap = new
|
|
36
|
+
this._renderQueueMap = new Map();
|
|
34
37
|
this._changeTag = 0;
|
|
35
38
|
this._bindGroupAllocator = new InstanceBindGroupAllocator();
|
|
39
|
+
this._staticBV = false;
|
|
40
|
+
const bvCallback = (function() {
|
|
41
|
+
if (!this._staticBV) {
|
|
42
|
+
this.invalidateBoundingVolume();
|
|
43
|
+
}
|
|
44
|
+
}).bind(this);
|
|
36
45
|
this.on('nodeattached', (node)=>{
|
|
37
46
|
node.iterate((child)=>{
|
|
38
|
-
if (child.
|
|
39
|
-
if (!child.isMesh()) {
|
|
40
|
-
console.error('Only mesh node can be added to batch group');
|
|
41
|
-
}
|
|
47
|
+
if (child.isMesh()) {
|
|
42
48
|
child.placeToOctree = false;
|
|
49
|
+
if (!this._staticBV) {
|
|
50
|
+
this.invalidateBoundingVolume();
|
|
51
|
+
}
|
|
52
|
+
child.on('bvchanged', bvCallback);
|
|
53
|
+
this._changeTag++;
|
|
43
54
|
}
|
|
44
55
|
});
|
|
45
|
-
this._changeTag++;
|
|
46
56
|
});
|
|
47
57
|
this.on('noderemoved', (node)=>{
|
|
48
58
|
node.iterate((child)=>{
|
|
49
|
-
if (child.
|
|
59
|
+
if (child.isMesh()) {
|
|
50
60
|
child.placeToOctree = true;
|
|
61
|
+
if (!this._staticBV) {
|
|
62
|
+
this.invalidateBoundingVolume();
|
|
63
|
+
}
|
|
64
|
+
child.off('bvchanged', bvCallback);
|
|
65
|
+
this._changeTag++;
|
|
51
66
|
}
|
|
52
67
|
});
|
|
53
|
-
this._changeTag++;
|
|
54
68
|
});
|
|
55
69
|
}
|
|
56
70
|
/**
|
|
@@ -63,10 +77,42 @@ import '../material/pbrsg.js';
|
|
|
63
77
|
*/ isBatchGroup() {
|
|
64
78
|
return true;
|
|
65
79
|
}
|
|
66
|
-
/**
|
|
67
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Force the batch state to be rebuilt
|
|
82
|
+
*/ invalidate() {
|
|
83
|
+
this._changeTag++;
|
|
84
|
+
}
|
|
85
|
+
/** @internal */ _detached() {
|
|
86
|
+
// Usually the node will be garbage collected after it is detached,
|
|
87
|
+
// We should reset the render queue to release the render bundles.
|
|
88
|
+
this._renderQueueMap.forEach((val)=>{
|
|
89
|
+
val.queue.reset();
|
|
90
|
+
});
|
|
91
|
+
this.invalidate();
|
|
92
|
+
}
|
|
93
|
+
/** @internal */ _attached() {
|
|
94
|
+
// Reset the render queue when attached to a new scene.
|
|
95
|
+
this.invalidate();
|
|
96
|
+
}
|
|
97
|
+
/** @internal */ computeBoundingVolume() {
|
|
98
|
+
const bv = new BoundingBox();
|
|
99
|
+
const invWorldMatrix = Matrix4x4.invertAffine(this.worldMatrix);
|
|
100
|
+
bv.beginExtend();
|
|
101
|
+
this.iterate((node)=>{
|
|
102
|
+
if (node.isMesh()) {
|
|
103
|
+
Matrix4x4.multiplyAffine(invWorldMatrix, node.worldMatrix, tmpMatrix);
|
|
104
|
+
const wb = node.getBoundingVolume().transform(tmpMatrix).toAABB();
|
|
105
|
+
bv.extend(wb.minPoint);
|
|
106
|
+
bv.extend(wb.maxPoint);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
return bv.isValid() ? bv : null;
|
|
110
|
+
}
|
|
111
|
+
/** @internal */ setBoundingVolume(bv) {
|
|
112
|
+
this._staticBV = !!bv;
|
|
113
|
+
super.setBoundingVolume(bv);
|
|
68
114
|
}
|
|
69
|
-
|
|
115
|
+
/** @internal */ cull(cullVisitor) {
|
|
70
116
|
let queueInfo = this._renderQueueMap.get(cullVisitor.renderPass);
|
|
71
117
|
if (!queueInfo) {
|
|
72
118
|
queueInfo = {
|
|
@@ -91,7 +137,7 @@ import '../material/pbrsg.js';
|
|
|
91
137
|
cullVisitor.frustumCulling = frustumCulling;
|
|
92
138
|
cullVisitor.renderQueue = renderQueue;
|
|
93
139
|
}
|
|
94
|
-
|
|
140
|
+
cullVisitor.pushRenderQueue(queueInfo.queue);
|
|
95
141
|
}
|
|
96
142
|
}
|
|
97
143
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batchgroup.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"batchgroup.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Vector4 } from '@zephyr3d/base';
|
|
2
2
|
import './octree.js';
|
|
3
|
+
import '../values.js';
|
|
3
4
|
import '../app.js';
|
|
4
5
|
import '@zephyr3d/device';
|
|
5
6
|
import '../material/shader/helper.js';
|
|
@@ -15,7 +16,6 @@ import '../render/renderer.js';
|
|
|
15
16
|
import { SkyRenderer } from '../render/sky.js';
|
|
16
17
|
import '../render/clipmap.js';
|
|
17
18
|
import { EnvIBL, EnvHemisphericAmbient, EnvConstantAmbient, EnvShIBL } from '../render/envlight.js';
|
|
18
|
-
import '../render/watermesh.js';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Wrapper for environmant lighting
|
|
@@ -39,7 +39,7 @@ import '../render/watermesh.js';
|
|
|
39
39
|
this._strength = 1;
|
|
40
40
|
}
|
|
41
41
|
/** @internal */ getHash(ctx) {
|
|
42
|
-
return ctx.drawEnvLight ? `${this.type}:${this._envLight.hasRadiance() ? '1' : '0'}:${this._envLight.hasIrradiance() ? '1' : '0'}` : 'none';
|
|
42
|
+
return !ctx || ctx.drawEnvLight ? `${this.type}:${this._envLight.hasRadiance() ? '1' : '0'}:${this._envLight.hasIrradiance() ? '1' : '0'}` : 'none';
|
|
43
43
|
}
|
|
44
44
|
/** @internal */ get envLight() {
|
|
45
45
|
return this._envLight;
|
package/dist/scene/graph_node.js
CHANGED
|
@@ -43,11 +43,6 @@ import { SceneNode } from './scene_node.js';
|
|
|
43
43
|
return null;
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
|
-
* {@inheritDoc Drawable.getInvBindMatrix}
|
|
47
|
-
*/ getInvBindMatrix() {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
46
|
* {@inheritDoc Drawable.getSortDistance}
|
|
52
47
|
*/ getSortDistance(camera) {
|
|
53
48
|
const cameraWorldMatrix = camera.worldMatrix;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph_node.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"graph_node.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/scene/light.js
CHANGED
|
@@ -293,7 +293,7 @@ export class HemiSphericLight extends AmbientLight {
|
|
|
293
293
|
*/ isDirectionLight() {
|
|
294
294
|
return true;
|
|
295
295
|
}
|
|
296
|
-
/** @internal */ computeBoundingVolume(
|
|
296
|
+
/** @internal */ computeBoundingVolume() {
|
|
297
297
|
return null;
|
|
298
298
|
}
|
|
299
299
|
/** @internal */ computeUniforms() {
|
|
@@ -342,8 +342,8 @@ export class HemiSphericLight extends AmbientLight {
|
|
|
342
342
|
*/ isPointLight() {
|
|
343
343
|
return true;
|
|
344
344
|
}
|
|
345
|
-
/** @internal */ computeBoundingVolume(
|
|
346
|
-
const bbox =
|
|
345
|
+
/** @internal */ computeBoundingVolume() {
|
|
346
|
+
const bbox = new BoundingBox();
|
|
347
347
|
bbox.minPoint = new Vector3(-this._range, -this._range, -this._range);
|
|
348
348
|
bbox.maxPoint = new Vector3(this._range, this._range, this._range);
|
|
349
349
|
return bbox;
|
|
@@ -415,8 +415,8 @@ export class HemiSphericLight extends AmbientLight {
|
|
|
415
415
|
*/ isSpotLight() {
|
|
416
416
|
return true;
|
|
417
417
|
}
|
|
418
|
-
/** @internal */ computeBoundingVolume(
|
|
419
|
-
const bbox =
|
|
418
|
+
/** @internal */ computeBoundingVolume() {
|
|
419
|
+
const bbox = new BoundingBox();
|
|
420
420
|
const cosCutoff = Math.cos(this._cutoff);
|
|
421
421
|
const r = this._range / cosCutoff * Math.sqrt(1 - cosCutoff * cosCutoff);
|
|
422
422
|
bbox.minPoint = new Vector3(-r, -r, 0);
|
package/dist/scene/mesh.js
CHANGED
|
@@ -8,6 +8,7 @@ import { LambertMaterial } from '../material/lambert.js';
|
|
|
8
8
|
import '../material/blinn.js';
|
|
9
9
|
import '../material/unlit.js';
|
|
10
10
|
import { QUEUE_OPAQUE } from '../values.js';
|
|
11
|
+
import { RenderBundleWrapper } from '../render/renderbundle_wrapper.js';
|
|
11
12
|
import '../material/meshmaterial.js';
|
|
12
13
|
import '../material/grassmaterial.js';
|
|
13
14
|
import '../material/terrainmaterial.js';
|
|
@@ -25,11 +26,11 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
|
|
|
25
26
|
/** @internal */ _bboxChangeCallback;
|
|
26
27
|
/** @internal */ _animatedBoundingBox;
|
|
27
28
|
/** @internal */ _boneMatrices;
|
|
28
|
-
/** @internal */ _invBindMatrix;
|
|
29
29
|
/** @internal */ _morphData;
|
|
30
30
|
/** @internal */ _morphInfo;
|
|
31
31
|
/** @internal */ _instanceHash;
|
|
32
32
|
/** @internal */ _batchable;
|
|
33
|
+
/** @internal */ _pickTarget;
|
|
33
34
|
/** @internal */ _boundingBoxNode;
|
|
34
35
|
/** @internal */ _instanceColor;
|
|
35
36
|
/**
|
|
@@ -42,10 +43,12 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
|
|
|
42
43
|
this._castShadow = true;
|
|
43
44
|
this._animatedBoundingBox = null;
|
|
44
45
|
this._boneMatrices = null;
|
|
45
|
-
this._invBindMatrix = null;
|
|
46
46
|
this._morphData = null;
|
|
47
47
|
this._morphInfo = null;
|
|
48
48
|
this._instanceHash = null;
|
|
49
|
+
this._pickTarget = {
|
|
50
|
+
node: this
|
|
51
|
+
};
|
|
49
52
|
this._boundingBoxNode = null;
|
|
50
53
|
this._instanceColor = Vector4.zero();
|
|
51
54
|
this._batchable = Application.instance.deviceType !== 'webgl';
|
|
@@ -77,7 +80,13 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
|
|
|
77
80
|
/**
|
|
78
81
|
* {@inheritDoc Drawable.getPickTarget }
|
|
79
82
|
*/ getPickTarget() {
|
|
80
|
-
return this;
|
|
83
|
+
return this._pickTarget;
|
|
84
|
+
}
|
|
85
|
+
setPickTarget(node, label) {
|
|
86
|
+
this._pickTarget = {
|
|
87
|
+
node,
|
|
88
|
+
label
|
|
89
|
+
};
|
|
81
90
|
}
|
|
82
91
|
/** Wether the mesh node casts shadows */ get castShadow() {
|
|
83
92
|
return this._castShadow;
|
|
@@ -99,6 +108,7 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
|
|
|
99
108
|
}
|
|
100
109
|
this._instanceHash = this._primitive && this._material ? `${this.constructor.name}:${this._scene.id}:${this._primitive.id}:${this._material.instanceId}` : null;
|
|
101
110
|
this.invalidateBoundingVolume();
|
|
111
|
+
RenderBundleWrapper.drawableChanged(this);
|
|
102
112
|
}
|
|
103
113
|
}
|
|
104
114
|
/** Material of the mesh */ get material() {
|
|
@@ -106,8 +116,15 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
|
|
|
106
116
|
}
|
|
107
117
|
set material(m) {
|
|
108
118
|
if (this._material !== m) {
|
|
119
|
+
if (this._material) {
|
|
120
|
+
RenderBundleWrapper.materialDetached(this._material.coreMaterial, this);
|
|
121
|
+
}
|
|
109
122
|
this._material = m;
|
|
123
|
+
if (this._material) {
|
|
124
|
+
RenderBundleWrapper.materialAttached(this._material.coreMaterial, this);
|
|
125
|
+
}
|
|
110
126
|
this._instanceHash = this._primitive && this._material ? `${this.constructor.name}:${this._scene.id}:${this._primitive.id}:${this._material.instanceId}` : null;
|
|
127
|
+
RenderBundleWrapper.drawableChanged(this);
|
|
111
128
|
}
|
|
112
129
|
}
|
|
113
130
|
/** Wether to draw the bounding box of the mesh node */ get drawBoundingBox() {
|
|
@@ -146,19 +163,19 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
|
|
|
146
163
|
* Sets the texture that contains the bone matrices for skeletal animation
|
|
147
164
|
* @param matrices - The texture that contains the bone matrices
|
|
148
165
|
*/ setBoneMatrices(matrices) {
|
|
149
|
-
this._boneMatrices
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
* @param matrix - The matrix to set
|
|
154
|
-
*/ setInvBindMatrix(matrix) {
|
|
155
|
-
this._invBindMatrix = matrix;
|
|
166
|
+
if (this._boneMatrices !== matrices) {
|
|
167
|
+
this._boneMatrices = matrices;
|
|
168
|
+
RenderBundleWrapper.drawableChanged(this);
|
|
169
|
+
}
|
|
156
170
|
}
|
|
157
171
|
/**
|
|
158
172
|
* Sets the texture that contains the morph target data
|
|
159
173
|
* @param data - The texture that contains the morph target data
|
|
160
174
|
*/ setMorphData(data) {
|
|
161
|
-
this._morphData
|
|
175
|
+
if (this._morphData !== data) {
|
|
176
|
+
this._morphData = data;
|
|
177
|
+
RenderBundleWrapper.drawableChanged(this);
|
|
178
|
+
}
|
|
162
179
|
}
|
|
163
180
|
/**
|
|
164
181
|
* {@inheritDoc Drawable.getMorphData}
|
|
@@ -169,7 +186,10 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
|
|
|
169
186
|
* Sets the buffer that contains the morph target information
|
|
170
187
|
* @param info - The buffer that contains the morph target information
|
|
171
188
|
*/ setMorphInfo(info) {
|
|
172
|
-
this._morphInfo
|
|
189
|
+
if (this._morphInfo !== info) {
|
|
190
|
+
this._morphInfo = info;
|
|
191
|
+
RenderBundleWrapper.drawableChanged(this);
|
|
192
|
+
}
|
|
173
193
|
}
|
|
174
194
|
/**
|
|
175
195
|
* {@inheritDoc Drawable.getMorphInfo}
|
|
@@ -185,6 +205,7 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
|
|
|
185
205
|
this._primitive = null;
|
|
186
206
|
this._material = null;
|
|
187
207
|
super.dispose();
|
|
208
|
+
RenderBundleWrapper.drawableChanged(this);
|
|
188
209
|
}
|
|
189
210
|
/**
|
|
190
211
|
* {@inheritDoc Drawable.getQueueType}
|
|
@@ -218,17 +239,12 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
|
|
|
218
239
|
return this._boneMatrices;
|
|
219
240
|
}
|
|
220
241
|
/**
|
|
221
|
-
* {@inheritDoc Drawable.getInvBindMatrix}
|
|
222
|
-
*/ getInvBindMatrix() {
|
|
223
|
-
return this._invBindMatrix;
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
242
|
* {@inheritDoc Drawable.getXForm}
|
|
227
243
|
*/ getXForm() {
|
|
228
244
|
// mesh transform should be ignored when skinned
|
|
229
245
|
return this;
|
|
230
246
|
}
|
|
231
|
-
/** @internal */ computeBoundingVolume(
|
|
247
|
+
/** @internal */ computeBoundingVolume() {
|
|
232
248
|
let bbox;
|
|
233
249
|
if (this._animatedBoundingBox) {
|
|
234
250
|
bbox = this._animatedBoundingBox;
|
package/dist/scene/mesh.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mesh.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mesh.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/scene/octree.js
CHANGED
|
@@ -515,9 +515,12 @@ var OctreePlacement;
|
|
|
515
515
|
* @returns Head node of the located node chain
|
|
516
516
|
*/ locateNodeChain(candidate, center, radius) {
|
|
517
517
|
let level = this._chunks.length - 1;
|
|
518
|
-
while(level && this._chunks[level].getNodeSize() < 4 * radius){
|
|
518
|
+
while(level >= 0 && this._chunks[level].getNodeSize() < 4 * radius){
|
|
519
519
|
--level;
|
|
520
520
|
}
|
|
521
|
+
if (level < 0) {
|
|
522
|
+
return null;
|
|
523
|
+
}
|
|
521
524
|
const dim = this._chunks[level].getDimension();
|
|
522
525
|
const inv_node_size = 1 / this._chunks[level].getNodeSize();
|
|
523
526
|
const px = Math.floor((center.x + this._rootSize * 0.5) * inv_node_size);
|
|
@@ -595,7 +598,7 @@ var OctreePlacement;
|
|
|
595
598
|
}
|
|
596
599
|
}
|
|
597
600
|
resize(size) {
|
|
598
|
-
size = Math.max(nextPowerOf2(size), this._leafSize);
|
|
601
|
+
size = Math.max(nextPowerOf2(Math.ceil(size)), this._leafSize);
|
|
599
602
|
if (size === this._rootSize) {
|
|
600
603
|
return;
|
|
601
604
|
}
|
package/dist/scene/octree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"octree.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"octree.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -38,7 +38,9 @@ import { OctreeNode } from './octree.js';
|
|
|
38
38
|
const d = node.rayIntersect(this._rayLocal); // this._rayLocal.bboxIntersectionTestEx(node.getBoundingVolume().toAABB());
|
|
39
39
|
if (d !== null && d < this._intersectedDist) {
|
|
40
40
|
this._intersectedDist = d;
|
|
41
|
-
this._intersected =
|
|
41
|
+
this._intersected = {
|
|
42
|
+
node
|
|
43
|
+
};
|
|
42
44
|
return true;
|
|
43
45
|
}
|
|
44
46
|
}
|
|
@@ -50,7 +52,7 @@ import { OctreeNode } from './octree.js';
|
|
|
50
52
|
const d = node.primitive.raycast(this._rayLocal);
|
|
51
53
|
if (d !== null && d < this._intersectedDist) {
|
|
52
54
|
this._intersectedDist = d;
|
|
53
|
-
this._intersected = node.getPickTarget()
|
|
55
|
+
this._intersected = node.getPickTarget();
|
|
54
56
|
return true;
|
|
55
57
|
}
|
|
56
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"raycast_visitor.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"raycast_visitor.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/scene/scene.js
CHANGED
|
@@ -89,7 +89,7 @@ import { Environment } from './environment.js';
|
|
|
89
89
|
const raycastVisitor = new RaycastVisitor(ray, length);
|
|
90
90
|
this.octree.getRootNode().traverse(raycastVisitor);
|
|
91
91
|
return raycastVisitor.intersected ? {
|
|
92
|
-
|
|
92
|
+
target: raycastVisitor.intersected,
|
|
93
93
|
dist: raycastVisitor.intersectedDist,
|
|
94
94
|
point: raycastVisitor.intersectedPoint
|
|
95
95
|
} : null;
|
package/dist/scene/scene_node.js
CHANGED
|
@@ -162,17 +162,16 @@ import { XForm } from './xform.js';
|
|
|
162
162
|
}
|
|
163
163
|
/**
|
|
164
164
|
* Computes the bounding volume of the node
|
|
165
|
-
* @param bv - The output bounding volume
|
|
166
165
|
* @returns The output bounding volume
|
|
167
|
-
*/ computeBoundingVolume(
|
|
168
|
-
return
|
|
166
|
+
*/ computeBoundingVolume() {
|
|
167
|
+
return null;
|
|
169
168
|
}
|
|
170
169
|
/**
|
|
171
170
|
* Gets the bounding volume of the node
|
|
172
171
|
* @returns The bounding volume of the node
|
|
173
172
|
*/ getBoundingVolume() {
|
|
174
173
|
if (this._bvDirty) {
|
|
175
|
-
this._bv = this.computeBoundingVolume(
|
|
174
|
+
this._bv = this.computeBoundingVolume();
|
|
176
175
|
this._bvDirty = false;
|
|
177
176
|
}
|
|
178
177
|
return this._bv;
|
|
@@ -183,7 +182,8 @@ import { XForm } from './xform.js';
|
|
|
183
182
|
*/ setBoundingVolume(bv) {
|
|
184
183
|
if (bv !== this._bv) {
|
|
185
184
|
this._bv = bv;
|
|
186
|
-
this.
|
|
185
|
+
this._bvDirty = !this._bv;
|
|
186
|
+
this.invalidateWorldBoundingVolume(false);
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
/**
|
|
@@ -213,6 +213,7 @@ import { XForm } from './xform.js';
|
|
|
213
213
|
} else if (this.isGraphNode()) {
|
|
214
214
|
this._scene.invalidateNodePlacement(this);
|
|
215
215
|
}
|
|
216
|
+
this.dispatchEvent(this, 'bvchanged');
|
|
216
217
|
}
|
|
217
218
|
}
|
|
218
219
|
/** Clip mode */ get clipTestEnabled() {
|
|
@@ -236,6 +237,9 @@ import { XForm } from './xform.js';
|
|
|
236
237
|
const prevHidden = this.hidden;
|
|
237
238
|
this._visible = val;
|
|
238
239
|
if (prevHidden !== this.hidden) {
|
|
240
|
+
if (this.isGraphNode()) {
|
|
241
|
+
this._scene.invalidateNodePlacement(this);
|
|
242
|
+
}
|
|
239
243
|
this.notifyHiddenChanged();
|
|
240
244
|
}
|
|
241
245
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scene_node.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scene_node.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -37,14 +37,13 @@ class GrassCluster extends applyMixins(GrassClusterBase, mixinDrawable) {
|
|
|
37
37
|
return this._terrain.getInstanceColor();
|
|
38
38
|
}
|
|
39
39
|
getPickTarget() {
|
|
40
|
-
return
|
|
40
|
+
return {
|
|
41
|
+
node: this._terrain
|
|
42
|
+
};
|
|
41
43
|
}
|
|
42
44
|
getBoneMatrices() {
|
|
43
45
|
return null;
|
|
44
46
|
}
|
|
45
|
-
getInvBindMatrix() {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
47
|
getMorphData() {
|
|
49
48
|
return null;
|
|
50
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grass.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"grass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|