@zephyr3d/scene 0.4.0 → 0.6.0
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/dist/animation/animation.js +25 -117
- package/dist/animation/animation.js.map +1 -1
- package/dist/animation/animationset.js +191 -51
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/animationtrack.js +6 -18
- package/dist/animation/animationtrack.js.map +1 -1
- package/dist/animation/eulerrotationtrack.js +16 -6
- package/dist/animation/eulerrotationtrack.js.map +1 -1
- package/dist/animation/morphtarget.js +104 -0
- package/dist/animation/morphtarget.js.map +1 -0
- package/dist/animation/morphtrack.js +70 -0
- package/dist/animation/morphtrack.js.map +1 -0
- package/dist/animation/rotationtrack.js +15 -7
- package/dist/animation/rotationtrack.js.map +1 -1
- package/dist/animation/scaletrack.js +15 -7
- package/dist/animation/scaletrack.js.map +1 -1
- package/dist/animation/skeleton.js +107 -5
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/translationtrack.js +15 -7
- package/dist/animation/translationtrack.js.map +1 -1
- package/dist/app.js +4 -26
- package/dist/app.js.map +1 -1
- package/dist/asset/assetmanager.js +60 -109
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/dds/dds.js +77 -3
- package/dist/asset/loaders/dds/dds.js.map +1 -1
- package/dist/asset/loaders/dds/dds_loader.js +1 -1
- package/dist/asset/loaders/gltf/gltf_loader.js +287 -40
- package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
- package/dist/asset/loaders/image/tga_Loader.js +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 +16 -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 +9 -3
- 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 +200 -4
- package/dist/camera/camera.js.map +1 -1
- package/dist/index.d.ts +6406 -5786
- package/dist/index.js +12 -10
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +15 -4
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/lambert.js +26 -17
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +13 -2
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +103 -31
- 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 +16 -7
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +16 -7
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +2 -2
- package/dist/material/mixins/pbr/common.js +454 -19
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/pbrmr.js +28 -6
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js +27 -9
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/shader/helper.js +128 -23
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/unlit.js +8 -4
- package/dist/material/unlit.js.map +1 -1
- package/dist/posteffect/bloom.js +34 -53
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/compositor.js +48 -58
- 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 +55 -48
- 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 +306 -340
- 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 +8 -6
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/depthpass.js +30 -14
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable_mixin.js +70 -22
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/envlight.js +169 -33
- 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 +68 -28
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/objectcolorpass.js +51 -0
- package/dist/render/objectcolorpass.js.map +1 -0
- package/dist/render/render_queue.js +211 -158
- 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 +151 -35
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/renderpass.js +27 -20
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/shadowmap_pass.js +20 -14
- 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/render/weightedblended_oit.js +11 -28
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/batchgroup.js +60 -14
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +24 -3
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/graph_node.js +0 -14
- package/dist/scene/graph_node.js.map +1 -1
- package/dist/scene/light.js +5 -5
- package/dist/scene/mesh.js +62 -15
- 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 +6 -9
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +11 -8
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/terrain/grass.js +10 -2
- 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 +10 -2
- package/dist/scene/terrain/patch.js.map +1 -1
- package/dist/scene/terrain/quadtree.js +2 -2
- 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/esm.js +4 -22
- package/dist/shadow/esm.js.map +1 -1
- package/dist/shadow/shadowmapper.js +56 -31
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shadow/vsm.js +4 -24
- package/dist/shadow/vsm.js.map +1 -1
- 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/draco/decoder.js +116 -0
- package/dist/utility/draco/decoder.js.map +1 -0
- 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 +25 -1
- package/dist/values.js.map +1 -1
- package/package.json +5 -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/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":";;;;;;;;"}
|
|
@@ -14,12 +14,10 @@ import { Vector4 } from '@zephyr3d/base';
|
|
|
14
14
|
static _compositeProgram;
|
|
15
15
|
static _compositeBindGroup;
|
|
16
16
|
static _compositeRenderStates;
|
|
17
|
-
_accumBuffer;
|
|
18
17
|
/**
|
|
19
18
|
* Creates an instance of WeightedBlendedOIT class.
|
|
20
19
|
*/ constructor(){
|
|
21
20
|
super();
|
|
22
|
-
this._accumBuffer = null;
|
|
23
21
|
}
|
|
24
22
|
/**
|
|
25
23
|
* {@inheritDoc OIT.getType}
|
|
@@ -121,32 +119,17 @@ import { Vector4 } from '@zephyr3d/base';
|
|
|
121
119
|
drawFullscreenQuad(WeightedBlendedOIT._compositeRenderStates);
|
|
122
120
|
}
|
|
123
121
|
/** @internal */ getAccumFramebuffer(ctx, device) {
|
|
124
|
-
const
|
|
125
|
-
const
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
samplerOptions: {
|
|
136
|
-
mipFilter: 'none'
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
const accumAlpha = device.createTexture2D(device.type === 'webgl' ? 'rgba16f' : 'r16f', width, height, {
|
|
140
|
-
samplerOptions: {
|
|
141
|
-
mipFilter: 'none'
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
this._accumBuffer = device.createFrameBuffer([
|
|
145
|
-
accumColor,
|
|
146
|
-
accumAlpha
|
|
147
|
-
], ctx.depthTexture);
|
|
148
|
-
}
|
|
149
|
-
return this._accumBuffer;
|
|
122
|
+
const width = ctx.depthTexture.width;
|
|
123
|
+
const height = ctx.depthTexture.height;
|
|
124
|
+
const accumColor = device.pool.fetchTemporalTexture2D(false, 'rgba16f', width, height, false);
|
|
125
|
+
const accumAlpha = device.pool.fetchTemporalTexture2D(false, device.type === 'webgl' ? 'rgba16f' : 'r16f', width, height, false);
|
|
126
|
+
const fb = device.pool.createTemporalFramebuffer(true, [
|
|
127
|
+
accumColor,
|
|
128
|
+
accumAlpha
|
|
129
|
+
], ctx.depthTexture);
|
|
130
|
+
device.pool.releaseTexture(accumColor);
|
|
131
|
+
device.pool.releaseTexture(accumAlpha);
|
|
132
|
+
return fb;
|
|
150
133
|
}
|
|
151
134
|
/** @internal */ static getCompositeProgram(device) {
|
|
152
135
|
if (!this._compositeProgram) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"weightedblended_oit.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"weightedblended_oit.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';
|
|
@@ -14,8 +15,7 @@ import '../material/pbrsg.js';
|
|
|
14
15
|
import '../render/renderer.js';
|
|
15
16
|
import { SkyRenderer } from '../render/sky.js';
|
|
16
17
|
import '../render/clipmap.js';
|
|
17
|
-
import { EnvIBL, EnvHemisphericAmbient, EnvConstantAmbient } from '../render/envlight.js';
|
|
18
|
-
import '../render/watermesh.js';
|
|
18
|
+
import { EnvIBL, EnvHemisphericAmbient, EnvConstantAmbient, EnvShIBL } from '../render/envlight.js';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Wrapper for environmant lighting
|
|
@@ -27,6 +27,7 @@ import '../render/watermesh.js';
|
|
|
27
27
|
_ambientUp;
|
|
28
28
|
_radianceMap;
|
|
29
29
|
_irradianceMap;
|
|
30
|
+
_irradianceSH;
|
|
30
31
|
_strength;
|
|
31
32
|
/** @internal */ constructor(){
|
|
32
33
|
this._envLight = new EnvIBL();
|
|
@@ -38,7 +39,7 @@ import '../render/watermesh.js';
|
|
|
38
39
|
this._strength = 1;
|
|
39
40
|
}
|
|
40
41
|
/** @internal */ getHash(ctx) {
|
|
41
|
-
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';
|
|
42
43
|
}
|
|
43
44
|
/** @internal */ get envLight() {
|
|
44
45
|
return this._envLight;
|
|
@@ -83,6 +84,8 @@ import '../render/watermesh.js';
|
|
|
83
84
|
this._radianceMap = tex ?? null;
|
|
84
85
|
if (this.type === 'ibl') {
|
|
85
86
|
this._envLight.radianceMap = this._radianceMap;
|
|
87
|
+
} else if (this.type === 'ibl-sh') {
|
|
88
|
+
this._envLight.radianceMap = this._radianceMap;
|
|
86
89
|
}
|
|
87
90
|
}
|
|
88
91
|
/** Irradiance map for environment light type ibl */ get irradianceMap() {
|
|
@@ -94,6 +97,15 @@ import '../render/watermesh.js';
|
|
|
94
97
|
this._envLight.irradianceMap = this._irradianceMap;
|
|
95
98
|
}
|
|
96
99
|
}
|
|
100
|
+
/** Irradiance SH for environment light type ibl-sh */ get irradianceSH() {
|
|
101
|
+
return this._irradianceSH;
|
|
102
|
+
}
|
|
103
|
+
set irradianceSH(value) {
|
|
104
|
+
this._irradianceSH = value ?? null;
|
|
105
|
+
if (this.type === 'ibl-sh') {
|
|
106
|
+
this._envLight.irradianceSH = this._irradianceSH;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
97
109
|
/** The environment light type */ get type() {
|
|
98
110
|
return this._envLight?.getType() ?? 'none';
|
|
99
111
|
}
|
|
@@ -106,6 +118,15 @@ import '../render/watermesh.js';
|
|
|
106
118
|
if (this._envLight?.getType() !== val) {
|
|
107
119
|
this._envLight = new EnvIBL(this._radianceMap, this._irradianceMap);
|
|
108
120
|
}
|
|
121
|
+
this._envLight.radianceMap = this.radianceMap;
|
|
122
|
+
this._envLight.irradianceMap = this.irradianceMap;
|
|
123
|
+
break;
|
|
124
|
+
case 'ibl-sh':
|
|
125
|
+
if (this._envLight?.getType() !== val) {
|
|
126
|
+
this._envLight = new EnvShIBL(this._radianceMap, this._irradianceSH);
|
|
127
|
+
}
|
|
128
|
+
this._envLight.radianceMap = this.radianceMap;
|
|
129
|
+
this._envLight.irradianceSH = this.irradianceSH;
|
|
109
130
|
break;
|
|
110
131
|
case 'constant':
|
|
111
132
|
if (this._envLight?.getType() !== val) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"environment.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/scene/graph_node.js
CHANGED
|
@@ -15,7 +15,6 @@ import { SceneNode } from './scene_node.js';
|
|
|
15
15
|
* @param scene - The scene to which the node belongs
|
|
16
16
|
*/ constructor(scene){
|
|
17
17
|
super(scene);
|
|
18
|
-
this._renderOrder = 0;
|
|
19
18
|
this._octreeNode = null;
|
|
20
19
|
}
|
|
21
20
|
/** @internal */ get octreeNode() {
|
|
@@ -24,14 +23,6 @@ import { SceneNode } from './scene_node.js';
|
|
|
24
23
|
set octreeNode(node) {
|
|
25
24
|
this._octreeNode = node;
|
|
26
25
|
}
|
|
27
|
-
/**
|
|
28
|
-
* Render order of the node
|
|
29
|
-
*/ get renderOrder() {
|
|
30
|
-
return this._renderOrder;
|
|
31
|
-
}
|
|
32
|
-
set renderOrder(val) {
|
|
33
|
-
this._renderOrder = val;
|
|
34
|
-
}
|
|
35
26
|
/** Gets the name */ getName() {
|
|
36
27
|
return this._name;
|
|
37
28
|
}
|
|
@@ -52,11 +43,6 @@ import { SceneNode } from './scene_node.js';
|
|
|
52
43
|
return null;
|
|
53
44
|
}
|
|
54
45
|
/**
|
|
55
|
-
* {@inheritDoc Drawable.getInvBindMatrix}
|
|
56
|
-
*/ getInvBindMatrix() {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
46
|
* {@inheritDoc Drawable.getSortDistance}
|
|
61
47
|
*/ getSortDistance(camera) {
|
|
62
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,9 +26,11 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
|
|
|
25
26
|
/** @internal */ _bboxChangeCallback;
|
|
26
27
|
/** @internal */ _animatedBoundingBox;
|
|
27
28
|
/** @internal */ _boneMatrices;
|
|
28
|
-
/** @internal */
|
|
29
|
+
/** @internal */ _morphData;
|
|
30
|
+
/** @internal */ _morphInfo;
|
|
29
31
|
/** @internal */ _instanceHash;
|
|
30
32
|
/** @internal */ _batchable;
|
|
33
|
+
/** @internal */ _pickTarget;
|
|
31
34
|
/** @internal */ _boundingBoxNode;
|
|
32
35
|
/** @internal */ _instanceColor;
|
|
33
36
|
/**
|
|
@@ -40,8 +43,12 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
|
|
|
40
43
|
this._castShadow = true;
|
|
41
44
|
this._animatedBoundingBox = null;
|
|
42
45
|
this._boneMatrices = null;
|
|
43
|
-
this.
|
|
46
|
+
this._morphData = null;
|
|
47
|
+
this._morphInfo = null;
|
|
44
48
|
this._instanceHash = null;
|
|
49
|
+
this._pickTarget = {
|
|
50
|
+
node: this
|
|
51
|
+
};
|
|
45
52
|
this._boundingBoxNode = null;
|
|
46
53
|
this._instanceColor = Vector4.zero();
|
|
47
54
|
this._batchable = Application.instance.deviceType !== 'webgl';
|
|
@@ -73,7 +80,13 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
|
|
|
73
80
|
/**
|
|
74
81
|
* {@inheritDoc Drawable.getPickTarget }
|
|
75
82
|
*/ getPickTarget() {
|
|
76
|
-
return this;
|
|
83
|
+
return this._pickTarget;
|
|
84
|
+
}
|
|
85
|
+
setPickTarget(node, label) {
|
|
86
|
+
this._pickTarget = {
|
|
87
|
+
node,
|
|
88
|
+
label
|
|
89
|
+
};
|
|
77
90
|
}
|
|
78
91
|
/** Wether the mesh node casts shadows */ get castShadow() {
|
|
79
92
|
return this._castShadow;
|
|
@@ -95,6 +108,7 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
|
|
|
95
108
|
}
|
|
96
109
|
this._instanceHash = this._primitive && this._material ? `${this.constructor.name}:${this._scene.id}:${this._primitive.id}:${this._material.instanceId}` : null;
|
|
97
110
|
this.invalidateBoundingVolume();
|
|
111
|
+
RenderBundleWrapper.drawableChanged(this);
|
|
98
112
|
}
|
|
99
113
|
}
|
|
100
114
|
/** Material of the mesh */ get material() {
|
|
@@ -102,8 +116,15 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
|
|
|
102
116
|
}
|
|
103
117
|
set material(m) {
|
|
104
118
|
if (this._material !== m) {
|
|
119
|
+
if (this._material) {
|
|
120
|
+
RenderBundleWrapper.materialDetached(this._material.coreMaterial, this);
|
|
121
|
+
}
|
|
105
122
|
this._material = m;
|
|
123
|
+
if (this._material) {
|
|
124
|
+
RenderBundleWrapper.materialAttached(this._material.coreMaterial, this);
|
|
125
|
+
}
|
|
106
126
|
this._instanceHash = this._primitive && this._material ? `${this.constructor.name}:${this._scene.id}:${this._primitive.id}:${this._material.instanceId}` : null;
|
|
127
|
+
RenderBundleWrapper.drawableChanged(this);
|
|
107
128
|
}
|
|
108
129
|
}
|
|
109
130
|
/** Wether to draw the bounding box of the mesh node */ get drawBoundingBox() {
|
|
@@ -142,23 +163,49 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
|
|
|
142
163
|
* Sets the texture that contains the bone matrices for skeletal animation
|
|
143
164
|
* @param matrices - The texture that contains the bone matrices
|
|
144
165
|
*/ setBoneMatrices(matrices) {
|
|
145
|
-
this._boneMatrices
|
|
166
|
+
if (this._boneMatrices !== matrices) {
|
|
167
|
+
this._boneMatrices = matrices;
|
|
168
|
+
RenderBundleWrapper.drawableChanged(this);
|
|
169
|
+
}
|
|
146
170
|
}
|
|
147
171
|
/**
|
|
148
|
-
* Sets the
|
|
149
|
-
* @param
|
|
150
|
-
*/
|
|
151
|
-
this.
|
|
172
|
+
* Sets the texture that contains the morph target data
|
|
173
|
+
* @param data - The texture that contains the morph target data
|
|
174
|
+
*/ setMorphData(data) {
|
|
175
|
+
if (this._morphData !== data) {
|
|
176
|
+
this._morphData = data;
|
|
177
|
+
RenderBundleWrapper.drawableChanged(this);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* {@inheritDoc Drawable.getMorphData}
|
|
182
|
+
*/ getMorphData() {
|
|
183
|
+
return this._morphData;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Sets the buffer that contains the morph target information
|
|
187
|
+
* @param info - The buffer that contains the morph target information
|
|
188
|
+
*/ setMorphInfo(info) {
|
|
189
|
+
if (this._morphInfo !== info) {
|
|
190
|
+
this._morphInfo = info;
|
|
191
|
+
RenderBundleWrapper.drawableChanged(this);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* {@inheritDoc Drawable.getMorphInfo}
|
|
196
|
+
*/ getMorphInfo() {
|
|
197
|
+
return this._morphInfo;
|
|
152
198
|
}
|
|
153
199
|
/**
|
|
154
200
|
* {@inheritDoc Drawable.isBatchable}
|
|
155
201
|
*/ isBatchable() {
|
|
156
|
-
return this._batchable && !this._boneMatrices && this._material?.isBatchable();
|
|
202
|
+
return this._batchable && !this._boneMatrices && !this._morphData && this._material?.isBatchable();
|
|
157
203
|
}
|
|
158
204
|
/** Disposes the mesh node */ dispose() {
|
|
159
205
|
this._primitive = null;
|
|
160
206
|
this._material = null;
|
|
161
207
|
super.dispose();
|
|
208
|
+
RenderBundleWrapper.drawableChanged(this);
|
|
162
209
|
}
|
|
163
210
|
/**
|
|
164
211
|
* {@inheritDoc Drawable.getQueueType}
|
|
@@ -171,6 +218,11 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
|
|
|
171
218
|
return !this.material?.supportLighting();
|
|
172
219
|
}
|
|
173
220
|
/**
|
|
221
|
+
* {@inheritDoc Drawable.needSceneColor}
|
|
222
|
+
*/ needSceneColor() {
|
|
223
|
+
return this.material?.needSceneColor();
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
174
226
|
* {@inheritDoc Drawable.draw}
|
|
175
227
|
*/ draw(ctx) {
|
|
176
228
|
this.bind(ctx);
|
|
@@ -187,17 +239,12 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
|
|
|
187
239
|
return this._boneMatrices;
|
|
188
240
|
}
|
|
189
241
|
/**
|
|
190
|
-
* {@inheritDoc Drawable.getInvBindMatrix}
|
|
191
|
-
*/ getInvBindMatrix() {
|
|
192
|
-
return this._invBindMatrix;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
242
|
* {@inheritDoc Drawable.getXForm}
|
|
196
243
|
*/ getXForm() {
|
|
197
244
|
// mesh transform should be ignored when skinned
|
|
198
245
|
return this;
|
|
199
246
|
}
|
|
200
|
-
/** @internal */ computeBoundingVolume(
|
|
247
|
+
/** @internal */ computeBoundingVolume() {
|
|
201
248
|
let bbox;
|
|
202
249
|
if (this._animatedBoundingBox) {
|
|
203
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
|
@@ -81,18 +81,15 @@ import { Environment } from './environment.js';
|
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
83
|
* Cast a ray into the scene to get the closest object hit by the ray
|
|
84
|
-
*
|
|
85
|
-
* @param
|
|
86
|
-
* @param
|
|
84
|
+
*
|
|
85
|
+
* @param ray - The ray in world coordinate space
|
|
86
|
+
* @param length - Length of the ray
|
|
87
87
|
* @returns The closest object hit by the ray
|
|
88
|
-
*/ raycast(
|
|
89
|
-
const
|
|
90
|
-
const height = camera.viewport ? camera.viewport[3] : Application.instance.device.getViewport().height;
|
|
91
|
-
const ray = this.constructRay(camera, width, height, screenX, screenY);
|
|
92
|
-
const raycastVisitor = new RaycastVisitor(ray, camera.getFarPlane());
|
|
88
|
+
*/ raycast(ray, length = Infinity) {
|
|
89
|
+
const raycastVisitor = new RaycastVisitor(ray, length);
|
|
93
90
|
this.octree.getRootNode().traverse(raycastVisitor);
|
|
94
91
|
return raycastVisitor.intersected ? {
|
|
95
|
-
|
|
92
|
+
target: raycastVisitor.intersected,
|
|
96
93
|
dist: raycastVisitor.intersectedDist,
|
|
97
94
|
point: raycastVisitor.intersectedPoint
|
|
98
95
|
} : null;
|
package/dist/scene/scene.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scene.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scene.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|