@woosh/meep-engine 2.93.2 → 2.94.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/build/bundle-worker-terrain.js +1 -1
- package/build/meep.cjs +296 -233
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +296 -233
- package/package.json +1 -1
- package/src/core/bvh2/bvh3/BVH.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/BVH.js +4 -2
- package/src/core/bvh2/bvh3/build_triangle_morton_codes.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/build_triangle_morton_codes.js +2 -1
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +12 -1
- package/src/core/bvh2/bvh3/ebvh_build_hierarchy.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_hierarchy.js +11 -1
- package/src/core/bvh2/bvh3/ebvh_geometry_query_nearest_triangle_ray.d.ts +14 -0
- package/src/core/bvh2/bvh3/ebvh_geometry_query_nearest_triangle_ray.d.ts.map +1 -0
- package/src/core/bvh2/bvh3/ebvh_geometry_query_nearest_triangle_ray.js +146 -0
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray.d.ts +16 -0
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray.d.ts.map +1 -0
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray.js +90 -0
- package/src/core/color/Color.d.ts.map +1 -1
- package/src/core/color/Color.js +17 -7
- package/src/core/geom/2d/bvh/BVH2D.d.ts.map +1 -1
- package/src/core/geom/2d/bvh/BVH2D.js +24 -29
- package/src/core/geom/2d/bvh/BVH2D.spec.js +10 -9
- package/src/core/geom/2d/bvh/bvh2d_query_all_data_by_circle.spec.d.ts +2 -0
- package/src/core/geom/2d/bvh/bvh2d_query_all_data_by_circle.spec.d.ts.map +1 -0
- package/src/core/geom/2d/bvh/bvh2d_query_all_data_by_circle.spec.js +89 -0
- package/src/core/geom/2d/quad-tree/QuadTreeNode.spec.js +1 -1
- package/src/core/geom/3d/aabb/AABB3.d.ts.map +1 -1
- package/src/core/geom/3d/aabb/AABB3.js +8 -1
- package/src/core/geom/3d/aabb/aabb3_array_combine.d.ts.map +1 -1
- package/src/core/geom/3d/aabb/aabb3_array_combine.js +5 -0
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentric.js +2 -0
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.d.ts.map +1 -1
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.js +9 -1
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricGeometry.d.ts +16 -0
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricGeometry.d.ts.map +1 -0
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricGeometry.js +55 -0
- package/src/core/math/build_gaussian_kernel_1d.d.ts +8 -0
- package/src/core/math/build_gaussian_kernel_1d.d.ts.map +1 -0
- package/src/core/math/build_gaussian_kernel_1d.js +26 -0
- package/src/core/math/build_gaussian_kernel_2d.d.ts +10 -0
- package/src/core/math/build_gaussian_kernel_2d.d.ts.map +1 -0
- package/src/core/math/build_gaussian_kernel_2d.js +55 -0
- package/src/core/math/nextOdd.d.ts +8 -0
- package/src/core/math/nextOdd.d.ts.map +1 -0
- package/src/core/math/nextOdd.js +15 -0
- package/src/core/math/nextOdd.spec.d.ts +2 -0
- package/src/core/math/nextOdd.spec.d.ts.map +1 -0
- package/src/core/math/nextOdd.spec.js +9 -0
- package/src/engine/animation/clip/ecd_bind_animation_curve.d.ts.map +1 -1
- package/src/engine/animation/clip/ecd_bind_animation_curve.js +7 -3
- package/src/engine/animation/curve/prototypeGLTF.js +18 -11
- package/src/engine/ecs/Entity.js +1 -1
- package/src/engine/ecs/EntityComponentDataset.js +0 -14
- package/src/engine/ecs/computeComponentClassName.d.ts +2 -0
- package/src/engine/ecs/computeComponentClassName.d.ts.map +1 -0
- package/src/engine/ecs/computeComponentClassName.js +13 -0
- package/src/engine/graphics/ecs/light/binding/LightBinding.d.ts +2 -0
- package/src/engine/graphics/ecs/light/binding/LightBinding.d.ts.map +1 -1
- package/src/engine/graphics/ecs/light/binding/LightBinding.js +16 -0
- package/src/engine/graphics/ecs/light/binding/fp/FPLightBinding.d.ts +13 -2
- package/src/engine/graphics/ecs/light/binding/fp/FPLightBinding.d.ts.map +1 -1
- package/src/engine/graphics/ecs/light/binding/fp/FPLightBinding.js +37 -4
- package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.d.ts.map +1 -1
- package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +12 -8
- package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.d.ts +0 -9
- package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +100 -129
- package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +6 -4
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +11 -4
- package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.d.ts +2 -2
- package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.js +2 -2
- package/src/engine/graphics/texture/sampler/Sampler2D.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/Sampler2D.js +6 -4
- package/src/engine/graphics/texture/sampler/convertSampler2D2DataURL.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/convertSampler2D2DataURL.js +1 -2
- package/src/engine/graphics/texture/sampler/downloadSamplerAsPNG.d.ts +2 -2
- package/src/engine/graphics/texture/sampler/downloadSamplerAsPNG.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/downloadSamplerAsPNG.js +3 -3
- package/src/engine/graphics/texture/sampler/filter/sampler2d_blur_gaussian.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/filter/sampler2d_blur_gaussian.js +5 -31
- package/src/engine/graphics/texture/virtual/VirtualTextureMaterial.d.ts +3 -6
- package/src/engine/graphics/texture/virtual/VirtualTextureMaterial.d.ts.map +1 -1
- package/src/engine/graphics/texture/virtual/VirtualTextureMaterial.js +8 -27
- package/src/engine/graphics/texture/virtual/VirtualTextureMemoryMapping.d.ts +4 -0
- package/src/engine/graphics/texture/virtual/VirtualTextureMemoryMapping.d.ts.map +1 -1
- package/src/engine/graphics/texture/virtual/VirtualTextureMemoryMapping.js +12 -0
- package/src/engine/graphics/texture/virtual/VirtualTextureSystem.d.ts +29 -0
- package/src/engine/graphics/texture/virtual/VirtualTextureSystem.d.ts.map +1 -0
- package/src/engine/graphics/texture/virtual/VirtualTextureSystem.js +102 -0
- package/src/engine/graphics/texture/virtual/VirtualTextureUsageUpdater.js +1 -1
- package/src/engine/graphics/texture/virtual/prototype.js +221 -79
- package/src/generation/filtering/numeric/CellFilterCache.d.ts.map +1 -1
- package/src/generation/filtering/numeric/CellFilterCache.js +7 -7
- package/src/generation/filtering/numeric/complex/CellFilterFXAA.d.ts.map +1 -1
- package/src/generation/filtering/numeric/complex/CellFilterFXAA.js +9 -6
- package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.d.ts +1 -13
- package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.d.ts.map +1 -1
- package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +39 -111
- package/src/generation/grid/generation/discrete/GridTaskConnectRooms.d.ts.map +1 -1
- package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +6 -5
- package/src/generation/grid/generation/util/buildDistanceMapToObjective.d.ts +1 -1
- package/src/generation/grid/generation/util/buildDistanceMapToObjective.d.ts.map +1 -1
- package/src/generation/grid/generation/util/buildDistanceMapToObjective.js +5 -12
- package/src/core/math/makeNextOdd.d.ts +0 -8
- package/src/core/math/makeNextOdd.d.ts.map +0 -1
- package/src/core/math/makeNextOdd.js +0 -15
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
export class FPLightBinding extends LightBinding {
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @type {PointLight|null}
|
|
5
|
+
* @private
|
|
6
|
+
*/
|
|
7
|
+
private __light;
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @type {SignalBinding[]}
|
|
11
|
+
*/
|
|
12
|
+
bindings: SignalBinding[];
|
|
3
13
|
/**
|
|
4
14
|
* @param {LightContext} ctx
|
|
5
15
|
* @return {ForwardPlusRenderingPlugin}
|
|
@@ -8,7 +18,8 @@ export class FPLightBinding extends LightBinding {
|
|
|
8
18
|
private getPlugin;
|
|
9
19
|
link(ctx: any): void;
|
|
10
20
|
unlink(ctx: any): void;
|
|
21
|
+
#private;
|
|
11
22
|
}
|
|
12
23
|
import { LightBinding } from "../LightBinding.js";
|
|
13
|
-
import {
|
|
24
|
+
import { SignalBinding } from "../../../../../../core/events/signal/SignalBinding.js";
|
|
14
25
|
//# sourceMappingURL=FPLightBinding.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FPLightBinding.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/ecs/light/binding/fp/FPLightBinding.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FPLightBinding.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/ecs/light/binding/fp/FPLightBinding.js"],"names":[],"mappings":"AAIA;IAIQ;;;;OAIG;IACH,gBAAmB;IAEnB;;;OAGG;IACH,UAFU,aAAa,EAAE,CAEP;IAGtB;;;;OAIG;IACH,kBAEC;IAMD,qBAwCC;IAED,uBAeC;;CACJ;6BA3F4B,oBAAoB;8BAFnB,uDAAuD"}
|
|
@@ -1,11 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SignalBinding } from "../../../../../../core/events/signal/SignalBinding.js";
|
|
2
2
|
import { PointLight } from "../../../../render/forward_plus/model/PointLight.js";
|
|
3
|
+
import { LightBinding } from "../LightBinding.js";
|
|
3
4
|
|
|
4
5
|
export class FPLightBinding extends LightBinding {
|
|
5
6
|
constructor() {
|
|
6
7
|
super();
|
|
7
8
|
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @type {PointLight|null}
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
8
14
|
this.__light = null;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @type {SignalBinding[]}
|
|
19
|
+
*/
|
|
20
|
+
this.bindings = [];
|
|
9
21
|
}
|
|
10
22
|
|
|
11
23
|
/**
|
|
@@ -17,6 +29,10 @@ export class FPLightBinding extends LightBinding {
|
|
|
17
29
|
return ctx.system.__plugin.getValue();
|
|
18
30
|
}
|
|
19
31
|
|
|
32
|
+
#updateDistance() {
|
|
33
|
+
this.__light.radius.set(this.scaled_distance);
|
|
34
|
+
}
|
|
35
|
+
|
|
20
36
|
link(ctx) {
|
|
21
37
|
/**
|
|
22
38
|
*
|
|
@@ -29,11 +45,17 @@ export class FPLightBinding extends LightBinding {
|
|
|
29
45
|
const pl = new PointLight();
|
|
30
46
|
|
|
31
47
|
const cLight = this.__c_light;
|
|
48
|
+
const cTransform = this.__c_transform;
|
|
49
|
+
|
|
50
|
+
this.bindings.push(
|
|
51
|
+
new SignalBinding(cLight.distance.onChanged, this.#updateDistance, this),
|
|
52
|
+
new SignalBinding(cTransform.scale.onChanged, this.#updateDistance, this)
|
|
53
|
+
);
|
|
32
54
|
|
|
33
55
|
pl.intensity = cLight.intensity;
|
|
34
56
|
pl.color = cLight.color;
|
|
35
|
-
|
|
36
|
-
pl.position =
|
|
57
|
+
|
|
58
|
+
pl.position = cTransform.position;
|
|
37
59
|
|
|
38
60
|
/**
|
|
39
61
|
*
|
|
@@ -42,9 +64,15 @@ export class FPLightBinding extends LightBinding {
|
|
|
42
64
|
*/
|
|
43
65
|
cLight.__fp_light = pl;
|
|
44
66
|
|
|
67
|
+
this.__light = pl;
|
|
68
|
+
|
|
69
|
+
this.#updateDistance();
|
|
70
|
+
|
|
45
71
|
lightManager.addLight(pl);
|
|
46
72
|
|
|
47
|
-
this.
|
|
73
|
+
for (let i = 0; i < this.bindings.length; i++) {
|
|
74
|
+
this.bindings[i].link();
|
|
75
|
+
}
|
|
48
76
|
}
|
|
49
77
|
|
|
50
78
|
unlink(ctx) {
|
|
@@ -57,5 +85,10 @@ export class FPLightBinding extends LightBinding {
|
|
|
57
85
|
const lightManager = fp.getLightManager();
|
|
58
86
|
|
|
59
87
|
lightManager.removeLight(this.__light);
|
|
88
|
+
|
|
89
|
+
for (let i = 0; i < this.bindings.length; i++) {
|
|
90
|
+
this.bindings[i].unlink();
|
|
91
|
+
}
|
|
92
|
+
this.bindings.splice(0, this.bindings.length);
|
|
60
93
|
}
|
|
61
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreeLightBinding.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js"],"names":[],"mappings":"AAwEA;IAKQ;;;;OAIG;IACH,iBAAoB;IAEpB;;;;OAIG;IACH,qBAAwB;IAExB;;;;OAIG;IACH,qBAAiC;IAGrC,qBAYC;IAED,uBAcC;IAED;;;;OAIG;IACH,yBAEC;IAYD,+BAEC;IAUD,yBAuBC;IAED,2BAgBC;IAED,iCA0BC;IAGD,2BA0CC;
|
|
1
|
+
{"version":3,"file":"ThreeLightBinding.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js"],"names":[],"mappings":"AAwEA;IAKQ;;;;OAIG;IACH,iBAAoB;IAEpB;;;;OAIG;IACH,qBAAwB;IAExB;;;;OAIG;IACH,qBAAiC;IAGrC,qBAYC;IAED,uBAcC;IAED;;;;OAIG;IACH,yBAEC;IAYD,+BAEC;IAUD,yBAuBC;IAED,2BAgBC;IAED,iCA0BC;IAGD,2BA0CC;IA8CD,mCA6BC;CAEJ;6BAzV4B,oBAAoB"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { LightBinding } from "../LightBinding.js";
|
|
2
|
-
import { threeEnsureLightObject } from "./threeEnsureLightObject.js";
|
|
3
|
-
import { LightType } from "../../LightType.js";
|
|
4
|
-
import { applyRotation } from "./applyRotation.js";
|
|
5
|
-
import { threeUpdateTransform } from "../../../../util/threeUpdateTransform.js";
|
|
6
|
-
import { ShadowMap } from "../../shadow/ShadowMap.js";
|
|
7
|
-
import { CameraView } from "../../../../render/view/CameraView.js";
|
|
8
1
|
import { DoubleSide, Mesh, MeshDepthMaterial, RGBADepthPacking, Scene } from "three";
|
|
9
2
|
import { ThreeBypassRenderer } from "../../../../render/utils/ThreeBypassRenderer.js";
|
|
3
|
+
import { CameraView } from "../../../../render/view/CameraView.js";
|
|
4
|
+
import { threeUpdateTransform } from "../../../../util/threeUpdateTransform.js";
|
|
5
|
+
import { LightType } from "../../LightType.js";
|
|
6
|
+
import { ShadowMap } from "../../shadow/ShadowMap.js";
|
|
7
|
+
import { LightBinding } from "../LightBinding.js";
|
|
8
|
+
import { applyRotation } from "./applyRotation.js";
|
|
9
|
+
import { threeEnsureLightObject } from "./threeEnsureLightObject.js";
|
|
10
10
|
|
|
11
11
|
const shadow_scene = new Scene();
|
|
12
12
|
shadow_scene.autoUpdate = false;
|
|
@@ -147,7 +147,7 @@ export class ThreeLightBinding extends LightBinding {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
__apply_distance(v) {
|
|
150
|
-
this.__three_getLight().distance = this.
|
|
150
|
+
this.__three_getLight().distance = this.scaled_distance;
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
__apply_angle() {
|
|
@@ -314,6 +314,10 @@ export class ThreeLightBinding extends LightBinding {
|
|
|
314
314
|
applyRotation(this.__c_light, this.__c_transform.rotation);
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
+
__apply_scale() {
|
|
318
|
+
this.__three_getLight().distance = this.scaled_distance;
|
|
319
|
+
}
|
|
320
|
+
|
|
317
321
|
applySettings(settings) {
|
|
318
322
|
const light = this.__three_getLight();
|
|
319
323
|
|
package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js
CHANGED
|
@@ -1070,7 +1070,7 @@ function create_volume({
|
|
|
1070
1070
|
*
|
|
1071
1071
|
* @param {Vector3} position
|
|
1072
1072
|
* @param {ParameterLookupTable} lut
|
|
1073
|
-
* @return {{position: Vector1}}
|
|
1073
|
+
* @return {{position: Vector1, entity:Entity}}
|
|
1074
1074
|
*/
|
|
1075
1075
|
function make_symbol_view({
|
|
1076
1076
|
position,
|
|
@@ -34,15 +34,6 @@ export class GeometryBVHBatched {
|
|
|
34
34
|
* @param {THREE.BufferGeometry} geometry
|
|
35
35
|
*/
|
|
36
36
|
build(geometry: THREE.BufferGeometry): void;
|
|
37
|
-
/**
|
|
38
|
-
*
|
|
39
|
-
* @param {number[]} output
|
|
40
|
-
* @param {number} face_index
|
|
41
|
-
* @param {number} t
|
|
42
|
-
* @param {number} u
|
|
43
|
-
* @param {number} v
|
|
44
|
-
*/
|
|
45
|
-
construct_ray_hit(output: number[], face_index: number, t: number, u: number, v: number): void;
|
|
46
37
|
/**
|
|
47
38
|
*
|
|
48
39
|
* @param {number[]} output
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeometryBVHBatched.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GeometryBVHBatched.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js"],"names":[],"mappings":"AA4FA;IAEQ;;;;OAIG;IACH,cAAsB;IAEtB;;;;OAIG;IACH,mBAAsB;IAEtB;;;;OAIG;IACH,yBAA4B;IAE5B;;;;OAIG;IACH,6BAAgC;IAGhC;;;;OAIG;IACH,yBAAyB;IAG7B;;;OAGG;IACH,gBAFW,MAAM,cAAc,QAyB9B;IAGD;;;;;;;OAOG;IACH,gBANW,MAAM,EAAE,OACR,MAAM,EAAE,gBACR,MAAM,gBACN,MAAM,GACJ,MAAM,CAwElB;CACJ"}
|
|
@@ -1,26 +1,94 @@
|
|
|
1
1
|
import { BVH } from "../../../../core/bvh2/bvh3/BVH.js";
|
|
2
2
|
import { ebvh_build_for_geometry_morton } from "../../../../core/bvh2/bvh3/ebvh_build_for_geometry_morton.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
aabb3_signed_distance_sqr_to_point
|
|
6
|
-
} from "../../../../core/geom/3d/aabb/aabb3_signed_distance_sqr_to_point.js";
|
|
3
|
+
import { bvh_query_user_data_ray } from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_ray.js";
|
|
4
|
+
|
|
7
5
|
import {
|
|
8
|
-
|
|
9
|
-
} from "../../../../core/geom/3d/triangle/
|
|
6
|
+
computeTriangleRayIntersectionBarycentricGeometry
|
|
7
|
+
} from "../../../../core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricGeometry.js";
|
|
10
8
|
|
|
11
9
|
/**
|
|
12
10
|
*
|
|
13
11
|
* @type {number[]}
|
|
14
12
|
*/
|
|
15
|
-
const
|
|
13
|
+
const scratch_uint32_array = [];
|
|
16
14
|
/**
|
|
17
15
|
*
|
|
18
16
|
* @type {number[]}
|
|
19
17
|
*/
|
|
20
18
|
const v3_scratch_0 = [];
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @param {number[]} output
|
|
23
|
+
* @param {number[]} indices
|
|
24
|
+
* @param {number[]} positions
|
|
25
|
+
* @param {number} face_index
|
|
26
|
+
* @param {number} t
|
|
27
|
+
* @param {number} u
|
|
28
|
+
* @param {number} v
|
|
29
|
+
*/
|
|
30
|
+
function construct_ray_hit(
|
|
31
|
+
output,
|
|
32
|
+
indices, positions,
|
|
33
|
+
face_index,
|
|
34
|
+
t, u, v
|
|
35
|
+
) {
|
|
36
|
+
|
|
37
|
+
const index_offset = face_index * 3;
|
|
38
|
+
|
|
39
|
+
const a = indices[index_offset];
|
|
40
|
+
const b = indices[index_offset + 1];
|
|
41
|
+
const c = indices[index_offset + 2];
|
|
42
|
+
|
|
43
|
+
const a_address = a * 3;
|
|
44
|
+
const b_address = b * 3;
|
|
45
|
+
const c_address = c * 3;
|
|
46
|
+
|
|
47
|
+
const ax = positions[a_address];
|
|
48
|
+
const ay = positions[a_address + 1];
|
|
49
|
+
const az = positions[a_address + 2];
|
|
50
|
+
|
|
51
|
+
const bx = positions[b_address];
|
|
52
|
+
const by = positions[b_address + 1];
|
|
53
|
+
const bz = positions[b_address + 2];
|
|
54
|
+
|
|
55
|
+
const cx = positions[c_address];
|
|
56
|
+
const cy = positions[c_address + 1];
|
|
57
|
+
const cz = positions[c_address + 2];
|
|
58
|
+
|
|
59
|
+
// normal
|
|
60
|
+
|
|
61
|
+
// edge1 = a - b
|
|
62
|
+
const edge1_x = bx - ax;
|
|
63
|
+
const edge1_y = by - ay;
|
|
64
|
+
const edge1_z = bz - az;
|
|
65
|
+
|
|
66
|
+
// edge2 = c - a
|
|
67
|
+
const edge2_x = cx - ax;
|
|
68
|
+
const edge2_y = cy - ay;
|
|
69
|
+
const edge2_z = cz - az;
|
|
70
|
+
|
|
71
|
+
// compute position of intersection point
|
|
72
|
+
output[0] = ax + edge1_x * u + edge2_x * v;
|
|
73
|
+
output[1] = ay + edge1_y * u + edge2_y * v;
|
|
74
|
+
output[2] = az + edge1_z * u + edge2_z * v;
|
|
75
|
+
|
|
76
|
+
// Compute triangle normal
|
|
77
|
+
|
|
78
|
+
// normal = edge1 x edge2
|
|
79
|
+
const normal_x = edge1_y * edge2_z - edge1_z * edge2_y;
|
|
80
|
+
const normal_y = edge1_z * edge2_x - edge1_x * edge2_z;
|
|
81
|
+
const normal_z = edge1_x * edge2_y - edge1_y * edge2_x
|
|
82
|
+
|
|
83
|
+
output[3] = normal_x;
|
|
84
|
+
output[4] = normal_y;
|
|
85
|
+
output[5] = normal_z;
|
|
86
|
+
|
|
87
|
+
output[6] = t;
|
|
88
|
+
output[7] = u;
|
|
89
|
+
output[8] = v;
|
|
90
|
+
output[9] = face_index;
|
|
91
|
+
}
|
|
24
92
|
|
|
25
93
|
export class GeometryBVHBatched {
|
|
26
94
|
constructor() {
|
|
@@ -86,71 +154,10 @@ export class GeometryBVHBatched {
|
|
|
86
154
|
//
|
|
87
155
|
// ebvh_build_for_geometry_incremental(bvh, index_array, array_positions, 1);
|
|
88
156
|
|
|
157
|
+
// remove any extra unused space
|
|
89
158
|
bvh.trim();
|
|
90
159
|
}
|
|
91
160
|
|
|
92
|
-
/**
|
|
93
|
-
*
|
|
94
|
-
* @param {number[]} output
|
|
95
|
-
* @param {number} face_index
|
|
96
|
-
* @param {number} t
|
|
97
|
-
* @param {number} u
|
|
98
|
-
* @param {number} v
|
|
99
|
-
*/
|
|
100
|
-
construct_ray_hit(output, face_index, t, u, v) {
|
|
101
|
-
const indices = this.__geometry_index;
|
|
102
|
-
const positions = this.__geometry_positions;
|
|
103
|
-
|
|
104
|
-
const index_offset = face_index * 3;
|
|
105
|
-
|
|
106
|
-
const a = indices[index_offset];
|
|
107
|
-
const b = indices[index_offset + 1];
|
|
108
|
-
const c = indices[index_offset + 2];
|
|
109
|
-
|
|
110
|
-
const a_address = a * 3;
|
|
111
|
-
const b_address = b * 3;
|
|
112
|
-
const c_address = c * 3;
|
|
113
|
-
|
|
114
|
-
const ax = positions[a_address];
|
|
115
|
-
const ay = positions[a_address + 1];
|
|
116
|
-
const az = positions[a_address + 2];
|
|
117
|
-
|
|
118
|
-
const bx = positions[b_address];
|
|
119
|
-
const by = positions[b_address + 1];
|
|
120
|
-
const bz = positions[b_address + 2];
|
|
121
|
-
|
|
122
|
-
const cx = positions[c_address];
|
|
123
|
-
const cy = positions[c_address + 1];
|
|
124
|
-
const cz = positions[c_address + 2];
|
|
125
|
-
|
|
126
|
-
// normal
|
|
127
|
-
|
|
128
|
-
// edge1 = a - b
|
|
129
|
-
const edge1_x = bx - ax;
|
|
130
|
-
const edge1_y = by - ay;
|
|
131
|
-
const edge1_z = bz - az;
|
|
132
|
-
|
|
133
|
-
// edge2 = c - a
|
|
134
|
-
const edge2_x = cx - ax;
|
|
135
|
-
const edge2_y = cy - ay;
|
|
136
|
-
const edge2_z = cz - az;
|
|
137
|
-
|
|
138
|
-
// Compute triangle normal
|
|
139
|
-
|
|
140
|
-
// normal = edge1 x edge2
|
|
141
|
-
const normal_x = edge1_y * edge2_z - edge1_z * edge2_y;
|
|
142
|
-
const normal_y = edge1_z * edge2_x - edge1_x * edge2_z;
|
|
143
|
-
const normal_z = edge1_x * edge2_y - edge1_y * edge2_x
|
|
144
|
-
|
|
145
|
-
output[3] = normal_x;
|
|
146
|
-
output[4] = normal_y;
|
|
147
|
-
output[5] = normal_z;
|
|
148
|
-
|
|
149
|
-
output[6] = t;
|
|
150
|
-
output[7] = u;
|
|
151
|
-
output[8] = v;
|
|
152
|
-
output[9] = face_index;
|
|
153
|
-
}
|
|
154
161
|
|
|
155
162
|
/**
|
|
156
163
|
*
|
|
@@ -176,77 +183,44 @@ export class GeometryBVHBatched {
|
|
|
176
183
|
const bvh = this.__bvh;
|
|
177
184
|
|
|
178
185
|
// TODO we can unify BVH traversal with ray checks to reduce number of checks
|
|
179
|
-
const count =
|
|
186
|
+
const count = bvh_query_user_data_ray(
|
|
180
187
|
bvh, bvh.root,
|
|
181
|
-
|
|
188
|
+
scratch_uint32_array, 0,
|
|
182
189
|
origin_x, origin_y, origin_z,
|
|
183
190
|
direction_x, direction_y, direction_z
|
|
184
191
|
);
|
|
185
192
|
|
|
193
|
+
if (count === 0) {
|
|
194
|
+
// no bvh hit, early exit
|
|
195
|
+
return -1;
|
|
196
|
+
}
|
|
197
|
+
|
|
186
198
|
let best_t = max_distance;
|
|
187
199
|
|
|
188
200
|
let best_index = -1;
|
|
189
201
|
let best_u = 0;
|
|
190
202
|
let best_v = 0;
|
|
191
203
|
|
|
204
|
+
// check triangles found via BVH
|
|
192
205
|
for (let i = 0; i < count; i++) {
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
if (best_t < max_distance) {
|
|
197
|
-
// early bail-out
|
|
198
|
-
|
|
199
|
-
bvh.node_get_aabb(node_id, temp_aabb3);
|
|
200
|
-
|
|
201
|
-
const distance = aabb3_signed_distance_sqr_to_point(
|
|
202
|
-
temp_aabb3[0], temp_aabb3[1], temp_aabb3[2],
|
|
203
|
-
temp_aabb3[3], temp_aabb3[4], temp_aabb3[5],
|
|
204
|
-
ray[0], ray[1], ray[2]
|
|
205
|
-
);
|
|
206
|
-
|
|
207
|
-
if (distance > best_t * best_t) {
|
|
208
|
-
// whole AABB is too far
|
|
209
|
-
continue;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const triangle_index = bvh.node_get_user_data(node_id);
|
|
206
|
+
const triangle_index = scratch_uint32_array[i];
|
|
214
207
|
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
const a = indices[index_offset];
|
|
218
|
-
const b = indices[index_offset + 1];
|
|
219
|
-
const c = indices[index_offset + 2];
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
const a_address = a * 3;
|
|
223
|
-
const b_address = b * 3;
|
|
224
|
-
const c_address = c * 3;
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
const ax = positions[a_address];
|
|
228
|
-
const ay = positions[a_address + 1];
|
|
229
|
-
const az = positions[a_address + 2];
|
|
230
|
-
|
|
231
|
-
const bx = positions[b_address];
|
|
232
|
-
const by = positions[b_address + 1];
|
|
233
|
-
const bz = positions[b_address + 2];
|
|
234
|
-
|
|
235
|
-
const cx = positions[c_address];
|
|
236
|
-
const cy = positions[c_address + 1];
|
|
237
|
-
const cz = positions[c_address + 2];
|
|
238
|
-
|
|
239
|
-
const intersection_found = computeTriangleRayIntersectionBarycentric(
|
|
208
|
+
const intersection_found = computeTriangleRayIntersectionBarycentricGeometry(
|
|
240
209
|
v3_scratch_0,
|
|
241
210
|
origin_x, origin_y, origin_z,
|
|
242
211
|
direction_x, direction_y, direction_z,
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
cx, cy, cz
|
|
212
|
+
indices, triangle_index,
|
|
213
|
+
positions
|
|
246
214
|
);
|
|
247
215
|
|
|
248
|
-
if (intersection_found
|
|
249
|
-
|
|
216
|
+
if (!intersection_found) {
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const t = v3_scratch_0[0];
|
|
221
|
+
|
|
222
|
+
if (t < best_t && t > min_distance) {
|
|
223
|
+
best_t = t;
|
|
250
224
|
|
|
251
225
|
best_index = triangle_index;
|
|
252
226
|
best_u = v3_scratch_0[1];
|
|
@@ -256,14 +230,11 @@ export class GeometryBVHBatched {
|
|
|
256
230
|
}
|
|
257
231
|
|
|
258
232
|
if (best_t === max_distance) {
|
|
233
|
+
// no hit
|
|
259
234
|
return -1;
|
|
260
235
|
}
|
|
261
236
|
|
|
262
|
-
output
|
|
263
|
-
output[1] = origin_y + direction_y * best_t;
|
|
264
|
-
output[2] = origin_z + direction_z * best_t;
|
|
265
|
-
|
|
266
|
-
this.construct_ray_hit(output, best_index, best_t, best_u, best_v);
|
|
237
|
+
construct_ray_hit(output, indices, positions, best_index, best_t, best_u, best_v);
|
|
267
238
|
|
|
268
239
|
return best_t;
|
|
269
240
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PathTracer.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/PathTracer.js"],"names":[],"mappings":";AAgEA;IAGQ;;;OAGG;IACH,eAFU,GAAG,CAEiB;IAE9B;;;OAGG;IACH,QAFU,IAAI,MAAM,EAAE,cAAc,CAAC,CAEd;IAEvB;;;OAGG;IACH,UAFU,eAAe,CAEP;IAElB;;;OAGG;IACH,WAFU,IAAI,MAAM,cAAc,EAAE,kBAAkB,CAAC,CAE7B;IAE1B;;;OAGG;IACH,UAFU,IAAI,MAAM,YAAY,CAEP;IAEzB;;;;OAIG;IACH,6BAA8C;IAGlD;;;;OAIG;IACH,uBAHW,MAAM,cAAc,GACnB,kBAAkB,CAgB7B;IAED,iBAGC;IAED,uBAoCC;IAED;;;OAGG;IACH,qCAEC;IAED;;;;;OAKG;IACH,aAJW,MAAM,cAAc,YACpB,MAAM,QAAQ,aACd,IAAI,GAAC,MAAM,EAAE,QA6CvB;IAED;;;;;;OAMG;IACH,oBALW,MAAM,EAAE,uBAER,MAAM,KACN,MAAM,QA+ChB;IAED;;;;OAIG;IACH,qBAHW,MAAM,EAAE,OACR,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"PathTracer.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/PathTracer.js"],"names":[],"mappings":";AAgEA;IAGQ;;;OAGG;IACH,eAFU,GAAG,CAEiB;IAE9B;;;OAGG;IACH,QAFU,IAAI,MAAM,EAAE,cAAc,CAAC,CAEd;IAEvB;;;OAGG;IACH,UAFU,eAAe,CAEP;IAElB;;;OAGG;IACH,WAFU,IAAI,MAAM,cAAc,EAAE,kBAAkB,CAAC,CAE7B;IAE1B;;;OAGG;IACH,UAFU,IAAI,MAAM,YAAY,CAEP;IAEzB;;;;OAIG;IACH,6BAA8C;IAGlD;;;;OAIG;IACH,uBAHW,MAAM,cAAc,GACnB,kBAAkB,CAgB7B;IAED,iBAGC;IAED,uBAoCC;IAED;;;OAGG;IACH,qCAEC;IAED;;;;;OAKG;IACH,aAJW,MAAM,cAAc,YACpB,MAAM,QAAQ,aACd,IAAI,GAAC,MAAM,EAAE,QA6CvB;IAED;;;;;;OAMG;IACH,oBALW,MAAM,EAAE,uBAER,MAAM,KACN,MAAM,QA+ChB;IAED;;;;OAIG;IACH,qBAHW,MAAM,EAAE,OACR,MAAM,EAAE,QAmFlB;IAED;;;;;;;OAOG;IACH,WANW,MAAM,EAAE,OACR,MAAM,EAAE,gBACR,MAAM,gBACN,MAAM,GACL,MAAM,CAyCjB;IAED;;;;;;OAMG;IACH,uBALW,MAAM,EAAE,cACR,MAAM,aACN,MAAM,EAAE,oBACR,MAAM,QAIhB;IAED;;;;;;OAMG;IACH,mBALW,MAAM,EAAE,cACR,MAAM,OACN,MAAM,EAAE,eACR,MAAM,WAgEhB;IAED,gGAyDC;CACJ;oBAriBmB,mCAAmC;+BAexB,qBAAqB;mCAHjB,yBAAyB;qBAtBjC,WAAW"}
|
|
@@ -261,7 +261,7 @@ export class PathTracer {
|
|
|
261
261
|
case LinearFilter:
|
|
262
262
|
case LinearMipmapLinearFilter:
|
|
263
263
|
|
|
264
|
-
sampler.
|
|
264
|
+
sampler.sampleBilinearUV(_u, _v, out);
|
|
265
265
|
break;
|
|
266
266
|
}
|
|
267
267
|
|
|
@@ -348,9 +348,11 @@ export class PathTracer {
|
|
|
348
348
|
const material = mesh.material;
|
|
349
349
|
|
|
350
350
|
if (material.isMeshStandardMaterial) {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
out[
|
|
351
|
+
const material_color = material.color;
|
|
352
|
+
|
|
353
|
+
out[0] *= material_color.r;
|
|
354
|
+
out[1] *= material_color.g;
|
|
355
|
+
out[2] *= material_color.b;
|
|
354
356
|
|
|
355
357
|
const diffuse_map = material.map;
|
|
356
358
|
|
|
@@ -67,6 +67,12 @@ vCanvas.css({
|
|
|
67
67
|
overflow: "visible"
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* How many rays to use per-pixel
|
|
72
|
+
* @type {number}
|
|
73
|
+
*/
|
|
74
|
+
const PIXEL_SAMPLE_COUNT = 256;
|
|
75
|
+
|
|
70
76
|
const pt = new PathTracer();
|
|
71
77
|
|
|
72
78
|
const gltfLoader = new GLTFLoader();
|
|
@@ -380,6 +386,7 @@ async function prepare_scene_rtiow(pt, camera) {
|
|
|
380
386
|
|
|
381
387
|
}
|
|
382
388
|
|
|
389
|
+
|
|
383
390
|
/**
|
|
384
391
|
*
|
|
385
392
|
* @param {Sampler2D} target
|
|
@@ -415,7 +422,7 @@ function* render(target, pt, camera, progress = { current: 0, total: 0 }) {
|
|
|
415
422
|
const pixel_scale_x = 1 / (width - 1);
|
|
416
423
|
const pixel_scale_y = 1 / (height - 1);
|
|
417
424
|
|
|
418
|
-
const pixel_sample_count =
|
|
425
|
+
const pixel_sample_count = PIXEL_SAMPLE_COUNT;
|
|
419
426
|
|
|
420
427
|
progress.total = width * height;
|
|
421
428
|
|
|
@@ -523,11 +530,11 @@ async function start_renderer(camera) {
|
|
|
523
530
|
|
|
524
531
|
// await prepare_scene_lucy(pt, camera);
|
|
525
532
|
// await prepare_scene_rtiow(pt, camera);
|
|
526
|
-
await prepare_scene_sphere_01(pt, camera);
|
|
527
|
-
|
|
533
|
+
// await prepare_scene_sphere_01(pt, camera);
|
|
534
|
+
await prepare_scene_gltf(pt, camera, path);
|
|
528
535
|
|
|
529
536
|
pt.build();
|
|
530
|
-
pt.optimize();
|
|
537
|
+
// pt.optimize();
|
|
531
538
|
|
|
532
539
|
const pixelRatio = 1;
|
|
533
540
|
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* @param {number} c vertex index 0
|
|
8
8
|
* @param {number[]} attribute_array
|
|
9
9
|
* @param {number} dimensions
|
|
10
|
-
* @param {number} u
|
|
11
|
-
* @param {number} v
|
|
10
|
+
* @param {number} u Barycentric coordinate
|
|
11
|
+
* @param {number} v Barycentric coordinate
|
|
12
12
|
*/
|
|
13
13
|
export function sample_triangle_attribute(out: number[], out_offset: number, a: number, b: number, c: number, attribute_array: number[], dimensions: number, u: number, v: number): void;
|
|
14
14
|
//# sourceMappingURL=sample_triangle_attribute.d.ts.map
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* @param {number} c vertex index 0
|
|
8
8
|
* @param {number[]} attribute_array
|
|
9
9
|
* @param {number} dimensions
|
|
10
|
-
* @param {number} u
|
|
11
|
-
* @param {number} v
|
|
10
|
+
* @param {number} u Barycentric coordinate
|
|
11
|
+
* @param {number} v Barycentric coordinate
|
|
12
12
|
*/
|
|
13
13
|
export function sample_triangle_attribute(
|
|
14
14
|
out, out_offset,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sampler2D.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/sampler/Sampler2D.js"],"names":[],"mappings":"AAoBA;;;;GAIG;AACH;
|
|
1
|
+
{"version":3,"file":"Sampler2D.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/sampler/Sampler2D.js"],"names":[],"mappings":"AAoBA;;;;GAIG;AACH;IAk8BI;;;;;;OAMG;IACH,6DAFY,SAAS,CAKpB;IAED;;;;;;OAMG;IACH,sDAFY,SAAS,CAKpB;IAED;;;;;;OAMG;IACH,uDAFY,SAAS,CAKpB;IAED;;;;;;OAMG;IACH,uDAFY,SAAS,CAKpB;IAED;;;;;;OAMG;IACH,qDAFY,SAAS,CAKpB;IAED;;;;;;OAMG;IACH,sDAFY,SAAS,CAKpB;IAED;;;;;;OAMG;IACH,sDAFY,SAAS,CAKpB;IAED;;;;;;OAMG;IACH,wDAFY,SAAS,CAKpB;IAED;;;;;;OAMG;IACH,wDAFY,SAAS,CAKpB;IA3iCD;;;;;;;OAOG;IACH,mBANW,UAAU,MAAM,CAAC,GAAC,MAAM,EAAE,GAAC,iBAAiB,GAAC,UAAU,GAAC,WAAW,GAAC,WAAW,GAAC,SAAS,GAAC,UAAU,GAAC,UAAU,GAAC,YAAY,GAAC,YAAY,aACzI,MAAM,UACN,MAAM,WACN,MAAM,EAmDhB;IA7BG;;;OAGG;IACH,cAAkB;IAElB;;;OAGG;IACH,eAAoB;IAEpB;;;OAGG;IACH,iBAAwB;IAExB;;;OAGG;IACH,MAFU,MAAM,EAAE,GAAC,iBAAiB,GAAC,UAAU,GAAC,WAAW,GAAC,WAAW,GAAC,SAAS,GAAC,UAAU,GAAC,UAAU,GAAC,YAAY,GAAC,YAAY,CAEjH;IAEhB;;;OAGG;IACH,SAFU,MAAM,CAEA;IAGpB;;;;;;;OAOG;IACH,OALW,MAAM,KACN,MAAM,UACN,qCAA+B,GAC7B,MAAM,CAIlB;IAED;;;;;OAKG;IACH,sBAJW,MAAM,KACN,MAAM,UACN,MAAM,EAAE,QAQlB;IAED;;;;;;OAMG;IACH,6BALW,MAAM,KACN,MAAM,WACN,MAAM,GACJ,MAAM,CAOlB;IAED;;;;;;;OAOG;IACH,2BALW,MAAM,KACN,MAAM,WACN,MAAM,GACJ,MAAM,CA2DlB;IAED;;;;;OAKG;IACH,mBAJW,MAAM,KACN,MAAM,UACN,MAAM,EAAE,QAQlB;IAED;;;;;;OAMG;IACH,iBALW,MAAM,KACN,MAAM,UACN,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,iBAClC,MAAM,QAUhB;IAED;;;;;;OAMG;IACH,0BALW,MAAM,KACN,MAAM,WACN,MAAM,GACJ,MAAM,CAOlB;IAED;;;;;;;OAOG;IACH,wBALW,MAAM,KACN,MAAM,WACN,MAAM,GACJ,MAAM,CAgFlB;IAED;;;;;;OAMG;IACH,oBALW,MAAM,KACN,MAAM,UACN,MAAM,EAAE,kBACR,MAAM,QAUhB;IAED;;;;;;OAMG;IACH,kBALW,MAAM,KACN,MAAM,UACN,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,kBAClC,MAAM,QAWhB;IAED;;;;;;OAMG;IACH,2BALW,MAAM,KACN,MAAM,WACN,MAAM,GACL,MAAM,CAOjB;IAED;;;;;;OAMG;IACH,yBALW,MAAM,KACN,MAAM,WACN,MAAM,GACJ,MAAM,CAiFlB;IAED;;;;;OAKG;IACH,mBAJW,MAAM,KACN,MAAM,UACN,UAAU,MAAM,CAAC,QAU3B;IAED;;;;;;OAMG;IACH,eALW,MAAM,KACN,MAAM,WACN,MAAM,GACJ,MAAM,CAalB;IAED;;;;;OAKG;IACH,QAJW,MAAM,KACN,MAAM,UACN,MAAM,EAAE,QAalB;IAED;;;;;OAKG;IACH,SAJW,MAAM,KACN,MAAM,QACN,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,QAapC;IAED;;;;;;OAMG;IACH,UALW,MAAM,KACN,MAAM,WACN,2BAAuB,OAajC;IAED;;;;;OAKG;IACH,eAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAIlB;IAED;;;;OAIG;IACH,mBAHW,MAAM,yBAUhB;IAED;;;;;;;;;OASG;IACH,aARW,SAAS,qHAoDnB;IAGD;;;;;;;OAOG;IACH,oEA8BC;IAED;;;;OAIG;IACH,2BAHW,MAAM,SACN,MAAM,QAYhB;IAED;;;;;;;OAOG;IACH,iEAFW,aAAc,QAqCxB;IAED;;;;;;OAMG;IACH,gBALW,MAAM,KACN,MAAM,WACN,MAAM,SACN,MAAM,QAqBhB;IAED;;;;;OAKG;IACH,OAJW,MAAM,KACN,MAAM,SACN,MAAM,EAAE,GAAC,YAAY,QAe/B;IAED;;;;;;;OAOG;IACH,wBALW,MAAM,WACN,MAAM,UACN,MAAM,sBAyBhB;IAED;;;;;OAKG;IACH,UAJW,MAAM,KACN,MAAM,iBACN,OAAO,QAyDjB;IAED;;;OAGG;IACH,mBAFY,MAAM,CAYjB;IAED;;;;OAIG;IACH,cAHW,SAAS,GACR,OAAO,CAYlB;IAED;;;OAGG;IACH,QAFY,MAAM,CAYjB;IAGD;;OAEG;IACH,SAFa,SAAS,CAerB;IAED;;;;;;MAUC;IAED;;;;;;aAwBC;IAgHL;;;OAGG;IACH,sBAFU,OAAO,CAEc;CAN9B;;kBAUS,MAAM"}
|
|
@@ -11,9 +11,9 @@ import {
|
|
|
11
11
|
import { is_typed_array_equals } from "../../../../core/collection/array/typed/is_typed_array_equals.js";
|
|
12
12
|
import { typedArrayToDataType } from "../../../../core/collection/array/typed/typedArrayToDataType.js";
|
|
13
13
|
import { clamp } from "../../../../core/math/clamp.js";
|
|
14
|
+
import { lerp } from "../../../../core/math/lerp.js";
|
|
14
15
|
import { max2 } from "../../../../core/math/max2.js";
|
|
15
16
|
import { min2 } from "../../../../core/math/min2.js";
|
|
16
|
-
import { mix } from "../../../../core/math/mix.js";
|
|
17
17
|
import { interpolate_bicubic } from "../../../../core/math/spline/interpolate_bicubic.js";
|
|
18
18
|
import { computeStridedIntegerArrayHash } from "../../../../core/primitives/array/computeStridedIntegerArrayHash.js";
|
|
19
19
|
import { typedArrayConstructorByInstance } from "./typedArrayConstructorByInstance.js";
|
|
@@ -235,6 +235,7 @@ export class Sampler2D {
|
|
|
235
235
|
}
|
|
236
236
|
|
|
237
237
|
/**
|
|
238
|
+
* TODO there is an oversaturation bug in here somewhere, prefer to use linear sampling for now instead
|
|
238
239
|
* Bicubic-filtered sampling
|
|
239
240
|
* @param {number} x
|
|
240
241
|
* @param {number} y
|
|
@@ -430,6 +431,7 @@ export class Sampler2D {
|
|
|
430
431
|
const q0 = data[i0];
|
|
431
432
|
|
|
432
433
|
if (x0 === x1 && y0 === y1) {
|
|
434
|
+
// exactly sampled in the center of the pixel, no interpolation required
|
|
433
435
|
return q0;
|
|
434
436
|
}
|
|
435
437
|
|
|
@@ -451,10 +453,10 @@ export class Sampler2D {
|
|
|
451
453
|
const p1 = data[j1];
|
|
452
454
|
|
|
453
455
|
// perform Bi-Linear interpolation
|
|
454
|
-
const s0 =
|
|
455
|
-
const s1 =
|
|
456
|
+
const s0 = lerp(q0, q1, xd);
|
|
457
|
+
const s1 = lerp(p0, p1, xd);
|
|
456
458
|
|
|
457
|
-
return
|
|
459
|
+
return lerp(s0, s1, yd);
|
|
458
460
|
}
|
|
459
461
|
|
|
460
462
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertSampler2D2DataURL.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/sampler/convertSampler2D2DataURL.js"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,8DAFa,MAAM,
|
|
1
|
+
{"version":3,"file":"convertSampler2D2DataURL.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/sampler/convertSampler2D2DataURL.js"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,8DAFa,MAAM,CAclB"}
|
|
@@ -12,8 +12,7 @@ export function convertSampler2D2DataURL(sampler) {
|
|
|
12
12
|
|
|
13
13
|
const canvasElement = document.createElement('canvas');
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const ctx = canvasElement.getContext("2d");
|
|
17
16
|
|
|
18
17
|
const { scale, offset } = sampler2d_compute_texel_value_conversion_scale_to_uint8(sampler);
|
|
19
18
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
*
|
|
3
3
|
* @param {Sampler2D} sampler
|
|
4
|
-
* @param {string} [
|
|
4
|
+
* @param {string} [file_name] what should the file be named?
|
|
5
5
|
*/
|
|
6
|
-
export function downloadSampler2DAsPNG(sampler: Sampler2D,
|
|
6
|
+
export function downloadSampler2DAsPNG(sampler: Sampler2D, file_name?: string): void;
|
|
7
7
|
//# sourceMappingURL=downloadSamplerAsPNG.d.ts.map
|