@zephyr3d/scene 0.5.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/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
|
@@ -23,7 +23,7 @@ import { BoundingBox } from '../../utility/bounding_volume.js';
|
|
|
23
23
|
for(let i = 0; i < this._heights.length; i++){
|
|
24
24
|
this._heights[i] = vertices[i].y;
|
|
25
25
|
}
|
|
26
|
-
this.createChildNode(this._rootNode, 0, 0, res_x, res_y, vertices);
|
|
26
|
+
this.createChildNode(this._rootNode, 0, 0, res_x - 1, res_y - 1, vertices);
|
|
27
27
|
return true;
|
|
28
28
|
}
|
|
29
29
|
getHeight(x, y) {
|
|
@@ -121,12 +121,6 @@ import { BoundingBox } from '../../utility/bounding_volume.js';
|
|
|
121
121
|
allocNode() {
|
|
122
122
|
return {
|
|
123
123
|
bbox: new BoundingBox(),
|
|
124
|
-
h: [
|
|
125
|
-
0,
|
|
126
|
-
0,
|
|
127
|
-
0,
|
|
128
|
-
0
|
|
129
|
-
],
|
|
130
124
|
rc: {
|
|
131
125
|
x: 0,
|
|
132
126
|
y: 0,
|
|
@@ -152,31 +146,38 @@ import { BoundingBox } from '../../utility/bounding_volume.js';
|
|
|
152
146
|
node.rc.y = y;
|
|
153
147
|
node.rc.w = w;
|
|
154
148
|
node.rc.h = h;
|
|
155
|
-
if (w <=
|
|
149
|
+
if (w <= 16 && h <= 16) {
|
|
156
150
|
node.left = null;
|
|
157
151
|
node.right = null;
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
152
|
+
let hMin = Infinity;
|
|
153
|
+
let hMax = -Infinity;
|
|
154
|
+
for(let i = x; i <= x + w; i++){
|
|
155
|
+
for(let j = y; j <= y + h; j++){
|
|
156
|
+
const h = this.getHeight(i, j);
|
|
157
|
+
if (h > hMax) {
|
|
158
|
+
hMax = h;
|
|
159
|
+
}
|
|
160
|
+
if (h < hMin) {
|
|
161
|
+
hMin = h;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
node.bbox = new BoundingBox(new Vector3(x * this._spacingX, hMin, y * this._spacingZ), new Vector3((x + w) * this._spacingX, hMax, (y + h) * this._spacingZ));
|
|
165
166
|
} else {
|
|
166
167
|
if (w >= h) {
|
|
167
|
-
const w1 = w
|
|
168
|
-
const w2 = w - w1
|
|
168
|
+
const w1 = w >> 1;
|
|
169
|
+
const w2 = w - w1;
|
|
169
170
|
node.left = this.allocNode();
|
|
170
171
|
this.createChildNode(node.left, x, y, w1, h, vertices);
|
|
171
172
|
node.right = this.allocNode();
|
|
172
|
-
this.createChildNode(node.right, x + w1
|
|
173
|
+
this.createChildNode(node.right, x + w1, y, w2, h, vertices);
|
|
173
174
|
} else {
|
|
174
|
-
const h1 = h
|
|
175
|
-
const h2 = h - h1
|
|
175
|
+
const h1 = h >> 1;
|
|
176
|
+
const h2 = h - h1;
|
|
176
177
|
node.left = this.allocNode();
|
|
177
178
|
this.createChildNode(node.left, x, y, w, h1, vertices);
|
|
178
179
|
node.right = this.allocNode();
|
|
179
|
-
this.createChildNode(node.right, x, y + h1
|
|
180
|
+
this.createChildNode(node.right, x, y + h1, w, h2, vertices);
|
|
180
181
|
}
|
|
181
182
|
node.bbox.beginExtend();
|
|
182
183
|
node.bbox.extend(node.left.bbox.minPoint);
|
|
@@ -187,45 +188,126 @@ import { BoundingBox } from '../../utility/bounding_volume.js';
|
|
|
187
188
|
return true;
|
|
188
189
|
}
|
|
189
190
|
rayIntersect(ray) {
|
|
190
|
-
return this.
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
191
|
+
return this.rayIntersectRecursive(ray);
|
|
192
|
+
}
|
|
193
|
+
rayIntersectLeaf(ray, node) {
|
|
194
|
+
let x0 = ray.origin.x;
|
|
195
|
+
let y0 = ray.origin.z;
|
|
196
|
+
let dx = ray.direction.x;
|
|
197
|
+
let dy = ray.direction.z;
|
|
198
|
+
const gridSizeX = this._spacingX;
|
|
199
|
+
const gridSizeY = this._spacingZ;
|
|
200
|
+
const x = node.rc.x;
|
|
201
|
+
const y = node.rc.y;
|
|
202
|
+
const w = node.rc.w;
|
|
203
|
+
const h = node.rc.h;
|
|
204
|
+
const epsl = 0.001;
|
|
205
|
+
let tx = 0;
|
|
206
|
+
let ty = 0;
|
|
207
|
+
const xmin = x * gridSizeX;
|
|
208
|
+
const xmax = xmin + w * gridSizeX;
|
|
209
|
+
const ymin = y * gridSizeY;
|
|
210
|
+
const ymax = ymin + h * gridSizeY;
|
|
211
|
+
const xcenter = (xmin + xmax) / 2;
|
|
212
|
+
const ycenter = (ymin + ymax) / 2;
|
|
213
|
+
let mirrorx = false;
|
|
214
|
+
let mirrory = false;
|
|
215
|
+
if (dx < 0) {
|
|
216
|
+
dx = -dx;
|
|
217
|
+
x0 += 2 * (xcenter - x0);
|
|
218
|
+
mirrorx = true;
|
|
196
219
|
}
|
|
197
|
-
if (
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
220
|
+
if (dy < 0) {
|
|
221
|
+
dy = -dy;
|
|
222
|
+
y0 += 2 * (ycenter - y0);
|
|
223
|
+
mirrory = true;
|
|
224
|
+
}
|
|
225
|
+
if (x0 < xmin) {
|
|
226
|
+
tx = (xmin - x0) / dx;
|
|
227
|
+
} else if (x0 > xmax) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
if (y0 < ymin) {
|
|
231
|
+
ty = (ymin - y0) / dy;
|
|
232
|
+
} else if (y0 > ymax) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const t = tx > ty ? tx : ty;
|
|
236
|
+
x0 += t * dx;
|
|
237
|
+
y0 += t * dy;
|
|
238
|
+
let u = Math.floor((x0 - xmin + epsl) / gridSizeX);
|
|
239
|
+
let v = Math.floor((y0 - ymin + epsl) / gridSizeY);
|
|
240
|
+
while(u >= 0 && u <= w && v >= 0 && v <= h){
|
|
241
|
+
if (u < w && v < h) {
|
|
242
|
+
const m = x + (mirrorx ? w - u - 1 : u);
|
|
243
|
+
const n = y + (mirrory ? h - v - 1 : v);
|
|
244
|
+
const v00 = new Vector3(m * this._spacingX, this.getHeight(m, n), n * this._spacingZ);
|
|
245
|
+
const v01 = new Vector3((m + 1) * this._spacingX, this.getHeight(m + 1, n), n * this._spacingZ);
|
|
246
|
+
const v11 = new Vector3((m + 1) * this._spacingX, this.getHeight(m + 1, n + 1), (n + 1) * this._spacingZ);
|
|
247
|
+
const v10 = new Vector3(m * this._spacingX, this.getHeight(m, n + 1), (n + 1) * this._spacingZ);
|
|
248
|
+
let intersected = false;
|
|
249
|
+
let dist1 = ray.intersectionTestTriangle(v00, v01, v10, false);
|
|
250
|
+
if (dist1 !== null && dist1 > 0) {
|
|
251
|
+
intersected = true;
|
|
252
|
+
} else {
|
|
253
|
+
dist1 = Number.MAX_VALUE;
|
|
254
|
+
}
|
|
255
|
+
let dist2 = ray.intersectionTestTriangle(v10, v01, v11, false);
|
|
256
|
+
if (dist2 !== null && dist2 > 0) {
|
|
257
|
+
intersected = true;
|
|
258
|
+
} else {
|
|
259
|
+
dist2 = Number.MAX_VALUE;
|
|
260
|
+
}
|
|
261
|
+
if (intersected) {
|
|
262
|
+
return dist1 < dist2 ? dist1 : dist2;
|
|
263
|
+
}
|
|
204
264
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
const v10 = new Vector3(node.bbox.minPoint.x, node.h[3], node.bbox.maxPoint.z);
|
|
210
|
-
let intersected = false;
|
|
211
|
-
let dist1 = ray.intersectionTestTriangle(v00, v01, v10, false);
|
|
212
|
-
if (dist1 !== null && dist1 > 0) {
|
|
213
|
-
intersected = true;
|
|
214
|
-
} else {
|
|
215
|
-
dist1 = Number.MAX_VALUE;
|
|
265
|
+
let d = Infinity;
|
|
266
|
+
if (dx > 0) {
|
|
267
|
+
const x1 = (u + x + 1) * gridSizeX;
|
|
268
|
+
d = Math.min(d, (x1 - x0) / dx);
|
|
216
269
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
} else {
|
|
221
|
-
dist2 = Number.MAX_VALUE;
|
|
270
|
+
if (dy !== 0) {
|
|
271
|
+
const y1 = (v + y + 1) * gridSizeY;
|
|
272
|
+
d = Math.min(d, (y1 - y0) / dy);
|
|
222
273
|
}
|
|
223
|
-
|
|
224
|
-
|
|
274
|
+
x0 += d * dx;
|
|
275
|
+
y0 += d * dy;
|
|
276
|
+
u = Math.floor((x0 - xmin + epsl) / gridSizeX);
|
|
277
|
+
v = Math.floor((y0 - ymin + epsl) / gridSizeY);
|
|
278
|
+
}
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
rayIntersectRecursive(ray) {
|
|
282
|
+
const q = [
|
|
283
|
+
this._rootNode
|
|
284
|
+
];
|
|
285
|
+
while(q.length > 0){
|
|
286
|
+
const node = q.shift();
|
|
287
|
+
if (!node.left) {
|
|
288
|
+
const d = this.rayIntersectLeaf(ray, node);
|
|
289
|
+
if (d !== null) {
|
|
290
|
+
return d;
|
|
291
|
+
}
|
|
225
292
|
} else {
|
|
226
|
-
|
|
293
|
+
const dl = ray.bboxIntersectionTestEx(node.left.bbox);
|
|
294
|
+
const dr = ray.bboxIntersectionTestEx(node.right.bbox);
|
|
295
|
+
if (dl !== null && dr !== null) {
|
|
296
|
+
if (dl < dr) {
|
|
297
|
+
q.unshift(node.right);
|
|
298
|
+
q.unshift(node.left);
|
|
299
|
+
} else {
|
|
300
|
+
q.unshift(node.left);
|
|
301
|
+
q.unshift(node.right);
|
|
302
|
+
}
|
|
303
|
+
} else if (dl !== null) {
|
|
304
|
+
q.unshift(node.left);
|
|
305
|
+
} else if (dr !== null) {
|
|
306
|
+
q.unshift(node.right);
|
|
307
|
+
}
|
|
227
308
|
}
|
|
228
309
|
}
|
|
310
|
+
return null;
|
|
229
311
|
}
|
|
230
312
|
}
|
|
231
313
|
/** @internal */ class HeightField {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heightfield.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"heightfield.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -81,7 +81,9 @@ import { mixinDrawable } from '../../render/drawable_mixin.js';
|
|
|
81
81
|
return this._terrain.getInstanceColor();
|
|
82
82
|
}
|
|
83
83
|
getPickTarget() {
|
|
84
|
-
return
|
|
84
|
+
return {
|
|
85
|
+
node: this._terrain
|
|
86
|
+
};
|
|
85
87
|
}
|
|
86
88
|
getMaterial() {
|
|
87
89
|
return this._terrain.material;
|
|
@@ -105,9 +107,6 @@ import { mixinDrawable } from '../../render/drawable_mixin.js';
|
|
|
105
107
|
getBoneMatrices() {
|
|
106
108
|
return null;
|
|
107
109
|
}
|
|
108
|
-
getInvBindMatrix() {
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
110
|
getMorphData() {
|
|
112
111
|
return null;
|
|
113
112
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"patch.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -201,7 +201,7 @@ import { GrassMaterial } from '../../material/grassmaterial.js';
|
|
|
201
201
|
/**
|
|
202
202
|
* {@inheritDoc SceneNode.computeBoundingVolume}
|
|
203
203
|
* @override
|
|
204
|
-
*/ computeBoundingVolume(
|
|
204
|
+
*/ computeBoundingVolume() {
|
|
205
205
|
return this._quadtree ? this._quadtree.getHeightField().getBBoxTree().getRootNode().bbox : null;
|
|
206
206
|
}
|
|
207
207
|
/**
|
package/dist/scene/xform.js
CHANGED
|
@@ -205,7 +205,7 @@ import { makeEventTarget, ObservableVector3, ObservableQuaternion, Matrix4x4, Ve
|
|
|
205
205
|
this.parent = p;
|
|
206
206
|
return this;
|
|
207
207
|
}
|
|
208
|
-
/** @internal */
|
|
208
|
+
/** @internal */ get transformTag() {
|
|
209
209
|
return this._transformTag;
|
|
210
210
|
}
|
|
211
211
|
/** @internal */ syncTRS() {
|
|
@@ -221,15 +221,13 @@ import { makeEventTarget, ObservableVector3, ObservableQuaternion, Matrix4x4, Ve
|
|
|
221
221
|
if (invalidateLocal) {
|
|
222
222
|
this._localMatrix = null;
|
|
223
223
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
this._invWorldMatrix = null;
|
|
227
|
-
this._transformTag++;
|
|
228
|
-
for (const child of this._children){
|
|
229
|
-
child._onTransformChanged(false);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
224
|
+
this._worldMatrix = null;
|
|
225
|
+
this._invWorldMatrix = null;
|
|
232
226
|
this._worldMatrixDet = null;
|
|
227
|
+
this._transformTag++;
|
|
228
|
+
for (const child of this._children){
|
|
229
|
+
child._onTransformChanged(false);
|
|
230
|
+
}
|
|
233
231
|
}
|
|
234
232
|
/** @internal */ _setParent(p) {
|
|
235
233
|
if (this._parent !== p) {
|
package/dist/scene/xform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xform.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"xform.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/shaders/misc.js
CHANGED
|
@@ -252,6 +252,15 @@ import { PBPrimitiveType, PBInsideFunctionScope } from '@zephyr3d/device';
|
|
|
252
252
|
});
|
|
253
253
|
return pb.getGlobalScope()[funcName](color);
|
|
254
254
|
}
|
|
255
|
+
/** @internal */ function fetchNormalizedFloatForDevice(scope, tex, uv, level) {
|
|
256
|
+
const pb = scope.$builder;
|
|
257
|
+
const texel = level === undefined || level === null ? pb.textureSample(tex, uv) : pb.textureSampleLevel(tex, uv, level);
|
|
258
|
+
if (pb.getDevice().type === 'webgl') {
|
|
259
|
+
return decodeNormalizedFloatFromRGBA(scope, texel);
|
|
260
|
+
} else {
|
|
261
|
+
return texel;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
255
264
|
|
|
256
|
-
export { decode2HalfFromRGBA, decodeFloatFromRGBA, decodeNormalizedFloatFromRGBA, decodeRGBM, encode2HalfToRGBA, encodeFloatToRGBA, encodeNormalizedFloatToRGBA, encodeRGBM, gammaToLinear, linearToGamma };
|
|
265
|
+
export { decode2HalfFromRGBA, decodeFloatFromRGBA, decodeNormalizedFloatFromRGBA, decodeRGBM, encode2HalfToRGBA, encodeFloatToRGBA, encodeNormalizedFloatToRGBA, encodeRGBM, fetchNormalizedFloatForDevice, gammaToLinear, linearToGamma };
|
|
257
266
|
//# sourceMappingURL=misc.js.map
|
package/dist/shaders/misc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"misc.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"misc.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/shaders/noise.js
CHANGED
|
@@ -1,32 +1,82 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Generate
|
|
2
|
+
* Generate random float value from a vec2
|
|
3
3
|
*
|
|
4
4
|
* @param scope - Current shader scope
|
|
5
5
|
* @param p - random seed
|
|
6
|
-
* @returns
|
|
6
|
+
* @returns random float value
|
|
7
7
|
*
|
|
8
8
|
* @public
|
|
9
|
-
*/ function
|
|
9
|
+
*/ function hash(scope, p) {
|
|
10
10
|
const pb = scope.$builder;
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
pb.func(funcNameHash, [
|
|
11
|
+
const funcName = 'Z_hashf';
|
|
12
|
+
pb.func(funcName, [
|
|
14
13
|
pb.vec2('p')
|
|
15
14
|
], function() {
|
|
16
|
-
this.h = pb.dot(this.p, pb.vec2(
|
|
15
|
+
this.h = pb.dot(this.p, pb.vec2(12.9898, 78.233));
|
|
17
16
|
this.$return(pb.fract(pb.mul(pb.sin(this.h), 43758.5453123)));
|
|
18
17
|
});
|
|
18
|
+
return scope[funcName](p);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Generate random float value from a vec2
|
|
22
|
+
*
|
|
23
|
+
* @param scope - Current shader scope
|
|
24
|
+
* @param p - random seed
|
|
25
|
+
* @returns random float value
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
*/ function gradient(scope, p, t) {
|
|
29
|
+
const pb = scope.$builder;
|
|
30
|
+
const funcName = 'Z_gradient2f';
|
|
31
|
+
pb.func(funcName, [
|
|
32
|
+
pb.vec2('p'),
|
|
33
|
+
pb.float('t')
|
|
34
|
+
], function() {
|
|
35
|
+
this.$l.rand = hash(this, this.p);
|
|
36
|
+
this.$l.angle = pb.mul(pb.add(this.t, Math.PI * 2), this.rand);
|
|
37
|
+
this.$return(pb.vec2(pb.cos(this.angle), pb.sin(this.angle)));
|
|
38
|
+
});
|
|
39
|
+
return scope[funcName](p, t);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Generate a float perlin noise value from a vec2
|
|
43
|
+
*
|
|
44
|
+
* @param scope - Current shader scope
|
|
45
|
+
* @param p - 2d vector
|
|
46
|
+
* @returns a float noise value
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
*/ function perlinNoise2D(scope, p) {
|
|
50
|
+
return perlinNoise3D(scope, scope.$builder.vec3(p, 0));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Generate a float perlin noise value from a vec3
|
|
54
|
+
*
|
|
55
|
+
* @param scope - Current shader scope
|
|
56
|
+
* @param p - 3d vector
|
|
57
|
+
* @returns a float noise value
|
|
58
|
+
*
|
|
59
|
+
* @public
|
|
60
|
+
*/ function perlinNoise3D(scope, p) {
|
|
61
|
+
const pb = scope.$builder;
|
|
62
|
+
const funcNameNoise = 'Z_perlinNoise3D';
|
|
19
63
|
pb.func(funcNameNoise, [
|
|
20
|
-
pb.
|
|
64
|
+
pb.vec3('p')
|
|
21
65
|
], function() {
|
|
22
|
-
this.i = pb.floor(this.p);
|
|
23
|
-
this.f = pb.
|
|
66
|
+
this.i = pb.floor(this.p.xy);
|
|
67
|
+
this.f = pb.sub(this.p.xy, this.i);
|
|
24
68
|
this.u = pb.mul(this.f, this.f, pb.sub(3, pb.mul(this.f, 2)));
|
|
25
|
-
this.h1 =
|
|
26
|
-
this.h2 = this
|
|
27
|
-
this.h3 = this
|
|
28
|
-
this.h4 = this
|
|
29
|
-
this.$
|
|
69
|
+
this.h1 = gradient(this, this.i, this.p.z);
|
|
70
|
+
this.h2 = gradient(this, pb.add(this.i, pb.vec2(1, 0)), this.p.z);
|
|
71
|
+
this.h3 = gradient(this, pb.add(this.i, pb.vec2(0, 1)), this.p.z);
|
|
72
|
+
this.h4 = gradient(this, pb.add(this.i, pb.vec2(1, 1)), this.p.z);
|
|
73
|
+
this.$l.tl = pb.dot(this.h1, this.f);
|
|
74
|
+
this.$l.tr = pb.dot(this.h2, pb.sub(this.f, pb.vec2(1, 0)));
|
|
75
|
+
this.$l.bl = pb.dot(this.h3, pb.sub(this.f, pb.vec2(0, 1)));
|
|
76
|
+
this.$l.br = pb.dot(this.h4, pb.sub(this.f, pb.vec2(1, 1)));
|
|
77
|
+
this.$l.noise = pb.mix(pb.mix(this.tl, this.tr, this.u.x), pb.mix(this.bl, this.br, this.u.x), this.u.y);
|
|
78
|
+
this.noise = pb.add(pb.mul(this.noise, 0.5), 0.5);
|
|
79
|
+
this.$return(this.noise);
|
|
30
80
|
});
|
|
31
81
|
return scope[funcNameNoise](p);
|
|
32
82
|
}
|
|
@@ -152,6 +202,21 @@
|
|
|
152
202
|
});
|
|
153
203
|
return pb.getGlobalScope()[funcName](p);
|
|
154
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* Calculate interleaved gradient noise
|
|
207
|
+
*
|
|
208
|
+
* @param scope - current shader scope
|
|
209
|
+
* @param c - 2d position at where to calculate noise
|
|
210
|
+
* @returns noise value
|
|
211
|
+
*
|
|
212
|
+
* @public
|
|
213
|
+
*/ function interleavedGradientNoise(scope, c) {
|
|
214
|
+
const pb = scope.$builder;
|
|
215
|
+
const x = 0.06711056;
|
|
216
|
+
const y = 0.00583715;
|
|
217
|
+
const z = 52.9829189;
|
|
218
|
+
return pb.fract(pb.mul(z, pb.fract(pb.dot(c, pb.vec2(x, y)))));
|
|
219
|
+
}
|
|
155
220
|
|
|
156
|
-
export { noise3D,
|
|
221
|
+
export { gradient, hash, interleavedGradientNoise, noise3D, perlinNoise2D, perlinNoise3D, smoothNoise3D, worleyFBM, worleyNoise };
|
|
157
222
|
//# sourceMappingURL=noise.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noise.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"noise.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/shaders/shadow.js
CHANGED
|
@@ -3,6 +3,7 @@ import { Application } from '../app.js';
|
|
|
3
3
|
import { LIGHT_TYPE_DIRECTIONAL, LIGHT_TYPE_POINT, LIGHT_TYPE_SPOT } from '../values.js';
|
|
4
4
|
import { encodeNormalizedFloatToRGBA, decode2HalfFromRGBA, decodeNormalizedFloatFromRGBA } from './misc.js';
|
|
5
5
|
import { ShaderHelper } from '../material/shader/helper.js';
|
|
6
|
+
import { interleavedGradientNoise } from './noise.js';
|
|
6
7
|
|
|
7
8
|
/*
|
|
8
9
|
const PCF_KERNEL_3x3 = [
|
|
@@ -354,15 +355,6 @@ function getShadowMapSize(scope) {
|
|
|
354
355
|
});
|
|
355
356
|
return pb.getGlobalScope()[funcNameComputeReceiverPlaneDepthBias](texCoord);
|
|
356
357
|
}
|
|
357
|
-
// reference: github.com/google/filament
|
|
358
|
-
function interleavedGradientNoise(scope, c) {
|
|
359
|
-
const pb = scope.$builder;
|
|
360
|
-
const x = 0.06711056;
|
|
361
|
-
const y = 0.00583715;
|
|
362
|
-
const z = 52.9829189;
|
|
363
|
-
return pb.fract(pb.mul(z, pb.fract(pb.dot(c, pb.vec2(x, y)))));
|
|
364
|
-
}
|
|
365
|
-
// reference: github.com/google/filament
|
|
366
358
|
function getRandomRotationMatrix(scope, fragCoord) {
|
|
367
359
|
const funcNameGetRandomRotationMatrix = 'lib_getRandomRotationMatrix';
|
|
368
360
|
const pb = scope.$builder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shadow.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shadow.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|