lythreeframe 1.0.21 → 1.0.23
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/bundle.cjs.js +109 -109
- package/dist/bundle.esm.js +7 -6
- package/dist/index.d.ts +5 -3
- package/dist/lythreeframe/AssetManagement/AssetManager.d.ts +1 -1
- package/dist/lythreeframe/AssetManagement/AssetPointer/AssetPointer.d.ts +1 -1
- package/dist/lythreeframe/Factory/CameraFactory.d.ts +3 -17
- package/dist/lythreeframe/Frame/Controller.d.ts +1 -1
- package/dist/lythreeframe/Frame/Parameters/AppParameter.d.ts +12 -0
- package/dist/lythreeframe/Frame/Parameters/CameraParameter.d.ts +16 -0
- package/dist/lythreeframe/Frame/Parameters/WorldParameter.d.ts +2 -0
- package/dist/lythreeframe/Frame/World.d.ts +1 -1
- package/dist/lythreeframe/Geometry/PlaneGeometry.d.ts +1 -1
- package/dist/lythreeframe/Geometry/TriangleGeometry.d.ts +1 -1
- package/dist/lythreeframe/Library/Math.d.ts +5 -5
- package/dist/lythreeframe/Library/ResourceLibrary.d.ts +1 -1
- package/dist/lythreeframe/Object/Actor.d.ts +5 -5
- package/dist/lythreeframe/Object/Actors/Light/DirectionalLightActor.d.ts +1 -1
- package/dist/lythreeframe/Object/Actors/Shape/BoxActor.d.ts +1 -1
- package/dist/lythreeframe/Object/Actors/Shape/PlaneActor.d.ts +1 -1
- package/dist/lythreeframe/Object/Actors/Sky/SkyActor.d.ts +8 -0
- package/dist/lythreeframe/Object/Components/2D/2DComponent.d.ts +1 -2
- package/dist/lythreeframe/Object/Components/Camera/CameraComponent.d.ts +1 -1
- package/dist/lythreeframe/Object/Components/Component.d.ts +1 -1
- package/dist/lythreeframe/Object/Components/Light/DirectionalLight/DirectionalLightComponent.d.ts +1 -1
- package/dist/lythreeframe/Object/Components/Light/LightComponent.d.ts +1 -1
- package/dist/lythreeframe/Object/Components/Mesh/InstanceMesh/InstanceMeshComponent.d.ts +1 -1
- package/dist/lythreeframe/Object/Components/Mesh/InstanceMesh/MultiInstanceMeshComponent.d.ts +1 -1
- package/dist/lythreeframe/Object/Components/Mesh/MeshComponent.d.ts +6 -7
- package/dist/lythreeframe/Object/Components/Mesh/Shape/BoxComponent.d.ts +1 -1
- package/dist/lythreeframe/Object/Components/Mesh/Shape/PlaneComponent.d.ts +1 -1
- package/dist/lythreeframe/Object/Components/Mesh/Shape/SphereComponent.d.ts +1 -2
- package/dist/lythreeframe/Object/Components/Mesh/Sprite/SpriteComponent.d.ts +1 -1
- package/dist/lythreeframe/Object/Components/SceneComponent.d.ts +13 -13
- package/dist/lythreeframe/Object/Components/Sky/SkyComponent.d.ts +20 -0
- package/dist/lythreeframe/Object/PawnV2/Oribital.d.ts +2 -2
- package/dist/lythreeframe/Object/PawnV2/Pawn.d.ts +2 -2
- package/dist/lythreeframe/Object/PawnV2/TransformControl.d.ts +1 -1
- package/dist/lythreeframe/PostProcess/Param/Outline.d.ts +1 -1
- package/dist/lythreeframe/PostProcess/Param/ToneMapping.d.ts +1 -1
- package/dist/lythreeframe/PostProcess/WebGPUPostProcessFactory.d.ts +1 -1
- package/dist/lythreeframe/ThreeJsApp.d.ts +3 -12
- package/package.json +5 -5
package/dist/bundle.cjs.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var webgpu = require('three/webgpu');
|
|
4
4
|
var Addons_js = require('three/examples/jsm/Addons.js');
|
|
5
5
|
var tsl = require('three/tsl');
|
|
6
|
-
var webgpu = require('three/webgpu');
|
|
7
6
|
var BloomNode_js = require('three/examples/jsm/tsl/display/BloomNode.js');
|
|
8
7
|
var DenoiseNode_js = require('three/examples/jsm/tsl/display/DenoiseNode.js');
|
|
9
8
|
var DepthOfFieldNode_js = require('three/examples/jsm/tsl/display/DepthOfFieldNode.js');
|
|
@@ -47,7 +46,7 @@ class BaseObject {
|
|
|
47
46
|
get uuid() {
|
|
48
47
|
return this._uuid;
|
|
49
48
|
}
|
|
50
|
-
constructor(uuid =
|
|
49
|
+
constructor(uuid = webgpu.MathUtils.generateUUID()) {
|
|
51
50
|
this.bCanTick = false;
|
|
52
51
|
this.bCanTick = false;
|
|
53
52
|
this._uuid = uuid;
|
|
@@ -132,7 +131,7 @@ class SceneComponent extends Component {
|
|
|
132
131
|
this._name = "SceneComponent";
|
|
133
132
|
}
|
|
134
133
|
createDefaultThreeObject() {
|
|
135
|
-
this.threeObject = new
|
|
134
|
+
this.threeObject = new webgpu.Group();
|
|
136
135
|
}
|
|
137
136
|
get isVisible() {
|
|
138
137
|
if (!this.threeObject) {
|
|
@@ -160,19 +159,19 @@ class SceneComponent extends Component {
|
|
|
160
159
|
});
|
|
161
160
|
}
|
|
162
161
|
getBoundsCenterPositionWS() {
|
|
163
|
-
let ret = new
|
|
162
|
+
let ret = new webgpu.Vector3();
|
|
164
163
|
this.getBounds().getCenter(ret);
|
|
165
164
|
return this.getWorldPosition();
|
|
166
165
|
}
|
|
167
166
|
getBoundsTopCenterPositionWS() {
|
|
168
|
-
let ret = new
|
|
167
|
+
let ret = new webgpu.Vector3();
|
|
169
168
|
let bounds = this.getBounds();
|
|
170
169
|
bounds.getCenter(ret);
|
|
171
170
|
ret.y = bounds.max.y;
|
|
172
171
|
return ret;
|
|
173
172
|
}
|
|
174
173
|
getBoundsBottomCenterPositionWS() {
|
|
175
|
-
let ret = new
|
|
174
|
+
let ret = new webgpu.Vector3();
|
|
176
175
|
let bounds = this.getBounds();
|
|
177
176
|
bounds.getCenter(ret);
|
|
178
177
|
ret.y = bounds.min.y;
|
|
@@ -182,7 +181,7 @@ class SceneComponent extends Component {
|
|
|
182
181
|
if (!this.threeObject) {
|
|
183
182
|
throw Error("threeObject is invalid");
|
|
184
183
|
}
|
|
185
|
-
let ret = new
|
|
184
|
+
let ret = new webgpu.Box3();
|
|
186
185
|
ret.setFromObject(this.threeObject, false);
|
|
187
186
|
if (ret.isEmpty()) {
|
|
188
187
|
ret.min = ret.max = this.getWorldPosition();
|
|
@@ -259,9 +258,9 @@ class SceneComponent extends Component {
|
|
|
259
258
|
return this.threeObject.position.clone();
|
|
260
259
|
}
|
|
261
260
|
else {
|
|
262
|
-
const position = new
|
|
263
|
-
const quaternion = new
|
|
264
|
-
const scale = new
|
|
261
|
+
const position = new webgpu.Vector3();
|
|
262
|
+
const quaternion = new webgpu.Quaternion();
|
|
263
|
+
const scale = new webgpu.Vector3();
|
|
265
264
|
this.threeObject.matrix.decompose(position, quaternion, scale);
|
|
266
265
|
return position;
|
|
267
266
|
}
|
|
@@ -271,14 +270,14 @@ class SceneComponent extends Component {
|
|
|
271
270
|
throw Error("threeObject is invalid");
|
|
272
271
|
}
|
|
273
272
|
let newPosition = null;
|
|
274
|
-
if (args.length === 1 && args[0] instanceof
|
|
275
|
-
newPosition = new
|
|
273
|
+
if (args.length === 1 && args[0] instanceof webgpu.Vector3) {
|
|
274
|
+
newPosition = new webgpu.Vector3().copy(args[0]);
|
|
276
275
|
}
|
|
277
276
|
else if (args.length === 3 &&
|
|
278
277
|
typeof args[0] === "number" &&
|
|
279
278
|
typeof args[1] === "number" &&
|
|
280
279
|
typeof args[2] === "number") {
|
|
281
|
-
newPosition = new
|
|
280
|
+
newPosition = new webgpu.Vector3(args[0], args[1], args[2]);
|
|
282
281
|
}
|
|
283
282
|
if (!newPosition) {
|
|
284
283
|
return;
|
|
@@ -302,11 +301,11 @@ class SceneComponent extends Component {
|
|
|
302
301
|
return this.threeObject.rotation.clone();
|
|
303
302
|
}
|
|
304
303
|
else {
|
|
305
|
-
const position = new
|
|
306
|
-
const quaternion = new
|
|
307
|
-
const scale = new
|
|
304
|
+
const position = new webgpu.Vector3();
|
|
305
|
+
const quaternion = new webgpu.Quaternion();
|
|
306
|
+
const scale = new webgpu.Vector3();
|
|
308
307
|
this.threeObject.matrix.decompose(position, quaternion, scale);
|
|
309
|
-
return new
|
|
308
|
+
return new webgpu.Euler().setFromQuaternion(quaternion);
|
|
310
309
|
}
|
|
311
310
|
}
|
|
312
311
|
setRotation(...args) {
|
|
@@ -314,11 +313,11 @@ class SceneComponent extends Component {
|
|
|
314
313
|
throw Error("threeObject is invalid");
|
|
315
314
|
}
|
|
316
315
|
let newRotation = null;
|
|
317
|
-
if (args[0] instanceof
|
|
318
|
-
newRotation = new
|
|
316
|
+
if (args[0] instanceof webgpu.Euler) {
|
|
317
|
+
newRotation = new webgpu.Euler().copy(args[0]);
|
|
319
318
|
}
|
|
320
319
|
if (typeof (args[0]) === "number" && typeof (args[1]) === "number" && typeof (args[2]) === "number") {
|
|
321
|
-
newRotation = new
|
|
320
|
+
newRotation = new webgpu.Euler(args[0], args[1], args[2]);
|
|
322
321
|
}
|
|
323
322
|
if (!newRotation) {
|
|
324
323
|
return;
|
|
@@ -339,9 +338,9 @@ class SceneComponent extends Component {
|
|
|
339
338
|
return this.threeObject.quaternion.clone();
|
|
340
339
|
}
|
|
341
340
|
else {
|
|
342
|
-
const position = new
|
|
343
|
-
const quaternion = new
|
|
344
|
-
const scale = new
|
|
341
|
+
const position = new webgpu.Vector3();
|
|
342
|
+
const quaternion = new webgpu.Quaternion();
|
|
343
|
+
const scale = new webgpu.Vector3();
|
|
345
344
|
this.threeObject.matrix.decompose(position, quaternion, scale);
|
|
346
345
|
return quaternion;
|
|
347
346
|
}
|
|
@@ -351,11 +350,11 @@ class SceneComponent extends Component {
|
|
|
351
350
|
throw Error("threeObject is invalid");
|
|
352
351
|
}
|
|
353
352
|
let newQuat = null;
|
|
354
|
-
if (args[0] instanceof
|
|
355
|
-
newQuat = new
|
|
353
|
+
if (args[0] instanceof webgpu.Quaternion) {
|
|
354
|
+
newQuat = new webgpu.Quaternion().copy(args[0]);
|
|
356
355
|
}
|
|
357
356
|
if (typeof args[0] === "number" && typeof args[1] === "number" && typeof args[2] === "number" && typeof args[3] === "number") {
|
|
358
|
-
newQuat = new
|
|
357
|
+
newQuat = new webgpu.Quaternion(args[0], args[1], args[2], args[3]);
|
|
359
358
|
}
|
|
360
359
|
if (!newQuat) {
|
|
361
360
|
console.error("setQuaternion failed,param is invalid", args);
|
|
@@ -363,9 +362,9 @@ class SceneComponent extends Component {
|
|
|
363
362
|
}
|
|
364
363
|
this.threeObject.quaternion.copy(newQuat);
|
|
365
364
|
if (!this.threeObject.matrixAutoUpdate) {
|
|
366
|
-
const position = new
|
|
367
|
-
const quaternion = new
|
|
368
|
-
const scale = new
|
|
365
|
+
const position = new webgpu.Vector3();
|
|
366
|
+
const quaternion = new webgpu.Quaternion();
|
|
367
|
+
const scale = new webgpu.Vector3();
|
|
369
368
|
this.threeObject.matrix.decompose(position, quaternion, scale);
|
|
370
369
|
this.threeObject.matrix.compose(position, newQuat, scale);
|
|
371
370
|
}
|
|
@@ -384,9 +383,9 @@ class SceneComponent extends Component {
|
|
|
384
383
|
return this.threeObject.scale.clone();
|
|
385
384
|
}
|
|
386
385
|
else {
|
|
387
|
-
const position = new
|
|
388
|
-
const quaternion = new
|
|
389
|
-
const scale = new
|
|
386
|
+
const position = new webgpu.Vector3();
|
|
387
|
+
const quaternion = new webgpu.Quaternion();
|
|
388
|
+
const scale = new webgpu.Vector3();
|
|
390
389
|
this.threeObject.matrix.decompose(position, quaternion, scale);
|
|
391
390
|
return scale;
|
|
392
391
|
}
|
|
@@ -396,11 +395,11 @@ class SceneComponent extends Component {
|
|
|
396
395
|
throw Error("threeObject is invalid");
|
|
397
396
|
}
|
|
398
397
|
let newScale = null;
|
|
399
|
-
if (args[0] instanceof
|
|
400
|
-
newScale = new
|
|
398
|
+
if (args[0] instanceof webgpu.Vector3) {
|
|
399
|
+
newScale = new webgpu.Vector3().copy(args[0]);
|
|
401
400
|
}
|
|
402
401
|
if (typeof (args[0]) === "number" && typeof (args[1]) === "number" && typeof (args[2]) === "number") {
|
|
403
|
-
newScale = new
|
|
402
|
+
newScale = new webgpu.Vector3(args[0], args[1], args[2]);
|
|
404
403
|
}
|
|
405
404
|
if (!newScale) {
|
|
406
405
|
return;
|
|
@@ -444,7 +443,7 @@ class SceneComponent extends Component {
|
|
|
444
443
|
if (!this.threeObject) {
|
|
445
444
|
throw Error("threeObject is invalid");
|
|
446
445
|
}
|
|
447
|
-
let location = new
|
|
446
|
+
let location = new webgpu.Vector3();
|
|
448
447
|
this.threeObject.getWorldPosition(location);
|
|
449
448
|
return location;
|
|
450
449
|
}
|
|
@@ -453,16 +452,16 @@ class SceneComponent extends Component {
|
|
|
453
452
|
if (!this.threeObject) {
|
|
454
453
|
throw Error("threeObject is invalid");
|
|
455
454
|
}
|
|
456
|
-
let rotation = new
|
|
455
|
+
let rotation = new webgpu.Quaternion();
|
|
457
456
|
this.threeObject.getWorldQuaternion(rotation);
|
|
458
|
-
return new
|
|
457
|
+
return new webgpu.Euler().setFromQuaternion(rotation);
|
|
459
458
|
}
|
|
460
459
|
// // rotation(quat)
|
|
461
460
|
getWorldQuaternion() {
|
|
462
461
|
if (!this.threeObject) {
|
|
463
462
|
throw Error("threeObject is invalid");
|
|
464
463
|
}
|
|
465
|
-
let rotation = new
|
|
464
|
+
let rotation = new webgpu.Quaternion();
|
|
466
465
|
this.threeObject.getWorldQuaternion(rotation);
|
|
467
466
|
return rotation;
|
|
468
467
|
}
|
|
@@ -471,7 +470,7 @@ class SceneComponent extends Component {
|
|
|
471
470
|
if (!this.threeObject) {
|
|
472
471
|
throw Error("threeObject is invalid");
|
|
473
472
|
}
|
|
474
|
-
let scale = new
|
|
473
|
+
let scale = new webgpu.Vector3();
|
|
475
474
|
this.threeObject.getWorldScale(scale);
|
|
476
475
|
return scale;
|
|
477
476
|
}
|
|
@@ -492,7 +491,7 @@ class SceneComponent extends Component {
|
|
|
492
491
|
// 计算父对象的逆世界矩阵
|
|
493
492
|
const parentInverseWorldMatrix = this.threeObject.parent.matrixWorld.clone().invert();
|
|
494
493
|
// 计算物体的本地矩阵
|
|
495
|
-
const cLocalMatrix = new
|
|
494
|
+
const cLocalMatrix = new webgpu.Matrix4().multiplyMatrices(parentInverseWorldMatrix, newMatrix);
|
|
496
495
|
// 更新物体的本地矩阵
|
|
497
496
|
this.setMatrix(cLocalMatrix);
|
|
498
497
|
// this.threeObject.matrix.copy(cLocalMatrix);
|
|
@@ -516,7 +515,7 @@ class SceneComponent extends Component {
|
|
|
516
515
|
if (!this.threeObject) {
|
|
517
516
|
throw Error("threeObject is invalid");
|
|
518
517
|
}
|
|
519
|
-
let ret = new
|
|
518
|
+
let ret = new webgpu.Vector3();
|
|
520
519
|
this.threeObject.getWorldDirection(ret);
|
|
521
520
|
return ret;
|
|
522
521
|
}
|
|
@@ -524,7 +523,7 @@ class SceneComponent extends Component {
|
|
|
524
523
|
if (!this.threeObject) {
|
|
525
524
|
throw Error("threeObject is invalid");
|
|
526
525
|
}
|
|
527
|
-
let ret = new
|
|
526
|
+
let ret = new webgpu.Vector3(0, 1, 0);
|
|
528
527
|
ret.applyQuaternion(this.getWorldQuaternion());
|
|
529
528
|
return ret;
|
|
530
529
|
}
|
|
@@ -532,7 +531,7 @@ class SceneComponent extends Component {
|
|
|
532
531
|
if (!this.threeObject) {
|
|
533
532
|
throw Error("threeObject is invalid");
|
|
534
533
|
}
|
|
535
|
-
let ret = new
|
|
534
|
+
let ret = new webgpu.Vector3(1, 0, 0);
|
|
536
535
|
ret.applyQuaternion(this.getWorldQuaternion());
|
|
537
536
|
return ret;
|
|
538
537
|
}
|
|
@@ -711,12 +710,12 @@ class MeshComponent extends SceneComponent {
|
|
|
711
710
|
}
|
|
712
711
|
constructor(...args) {
|
|
713
712
|
let newMesh = null;
|
|
714
|
-
if (args[0] instanceof
|
|
713
|
+
if (args[0] instanceof webgpu.Mesh) {
|
|
715
714
|
newMesh = args[0];
|
|
716
715
|
}
|
|
717
716
|
else {
|
|
718
|
-
if (args[0] instanceof
|
|
719
|
-
newMesh = new
|
|
717
|
+
if (args[0] instanceof webgpu.BufferGeometry && (args[1] instanceof webgpu.Material || Array.isArray(args[1]))) {
|
|
718
|
+
newMesh = new webgpu.Mesh(args[0], args[1]);
|
|
720
719
|
}
|
|
721
720
|
else {
|
|
722
721
|
throw new Error('Invalid arguments for A constructor');
|
|
@@ -744,19 +743,19 @@ class MeshComponent extends SceneComponent {
|
|
|
744
743
|
return this.threeObject ? this.threeObject.receiveShadow : false;
|
|
745
744
|
}
|
|
746
745
|
getBoundsCenterPosition() {
|
|
747
|
-
let ret = new
|
|
746
|
+
let ret = new webgpu.Vector3();
|
|
748
747
|
this.getBounds().getCenter(ret);
|
|
749
748
|
return ret;
|
|
750
749
|
}
|
|
751
750
|
getBoundsTopCenterPosition() {
|
|
752
|
-
let ret = new
|
|
751
|
+
let ret = new webgpu.Vector3();
|
|
753
752
|
let bounds = this.getBounds();
|
|
754
753
|
bounds.getCenter(ret);
|
|
755
754
|
ret.y = bounds.max.y;
|
|
756
755
|
return ret;
|
|
757
756
|
}
|
|
758
757
|
getBoundsBottomCenterPosition() {
|
|
759
|
-
let ret = new
|
|
758
|
+
let ret = new webgpu.Vector3();
|
|
760
759
|
let bounds = this.getBounds();
|
|
761
760
|
bounds.getCenter(ret);
|
|
762
761
|
ret.y = bounds.min.y;
|
|
@@ -769,9 +768,9 @@ class MeshComponent extends SceneComponent {
|
|
|
769
768
|
let assetManager = LYAssetManager.Get();
|
|
770
769
|
const mats = Array.isArray(this.material) ? this.material : [this.material];
|
|
771
770
|
mats.forEach((material) => {
|
|
772
|
-
if (material instanceof
|
|
771
|
+
if (material instanceof webgpu.Material) {
|
|
773
772
|
Object.entries(material).forEach(([key, value]) => {
|
|
774
|
-
if (value instanceof
|
|
773
|
+
if (value instanceof webgpu.Texture) {
|
|
775
774
|
assetManager.releaseAsset(value);
|
|
776
775
|
value = null;
|
|
777
776
|
}
|
|
@@ -780,7 +779,7 @@ class MeshComponent extends SceneComponent {
|
|
|
780
779
|
}
|
|
781
780
|
});
|
|
782
781
|
this.material = [];
|
|
783
|
-
if (this.geometry instanceof
|
|
782
|
+
if (this.geometry instanceof webgpu.BufferGeometry) {
|
|
784
783
|
assetManager.releaseAsset(this.geometry);
|
|
785
784
|
this.geometry = null;
|
|
786
785
|
}
|
|
@@ -854,7 +853,7 @@ class LYAssetManager {
|
|
|
854
853
|
constructor() {
|
|
855
854
|
this.assetPointer = new Map();
|
|
856
855
|
this.dracoLoader = null;
|
|
857
|
-
this.loadingManager = new
|
|
856
|
+
this.loadingManager = new webgpu.LoadingManager();
|
|
858
857
|
this.gltfLoader = new Addons_js.GLTFLoader(this.loadingManager);
|
|
859
858
|
}
|
|
860
859
|
get LoadingManager() {
|
|
@@ -922,7 +921,7 @@ class LYAssetManager {
|
|
|
922
921
|
textures: new Map()
|
|
923
922
|
};
|
|
924
923
|
gltf.scene.traverse((child) => {
|
|
925
|
-
if (child.geometry && child.geometry instanceof
|
|
924
|
+
if (child.geometry && child.geometry instanceof webgpu.BufferGeometry) {
|
|
926
925
|
countResource(resources.geometries, child.geometry);
|
|
927
926
|
}
|
|
928
927
|
if (child.material) {
|
|
@@ -931,7 +930,7 @@ class LYAssetManager {
|
|
|
931
930
|
if (mat) {
|
|
932
931
|
countResource(resources.materials, mat);
|
|
933
932
|
Object.entries(mat).forEach(([key, value]) => {
|
|
934
|
-
if (value instanceof
|
|
933
|
+
if (value instanceof webgpu.Texture) {
|
|
935
934
|
countResource(resources.textures, value);
|
|
936
935
|
}
|
|
937
936
|
});
|
|
@@ -966,7 +965,7 @@ class LYAssetManager {
|
|
|
966
965
|
this.addAsset(material);
|
|
967
966
|
}
|
|
968
967
|
Object.entries(material).forEach(([key, value]) => {
|
|
969
|
-
if (value instanceof
|
|
968
|
+
if (value instanceof webgpu.Texture) {
|
|
970
969
|
if (!value.userData["assetPointer"]) {
|
|
971
970
|
this.addAsset(value);
|
|
972
971
|
}
|
|
@@ -1010,7 +1009,7 @@ class LYAssetManager {
|
|
|
1010
1009
|
this.gltfLoader.parse(data, path, onLoadFinished);
|
|
1011
1010
|
}
|
|
1012
1011
|
loadFile(filepath = '', onLoadFinished) {
|
|
1013
|
-
const loader = new
|
|
1012
|
+
const loader = new webgpu.FileLoader();
|
|
1014
1013
|
loader.load(filepath, (data) => {
|
|
1015
1014
|
onLoadFinished(data);
|
|
1016
1015
|
});
|
|
@@ -1109,7 +1108,7 @@ class World {
|
|
|
1109
1108
|
constructor(app) {
|
|
1110
1109
|
this.actors = new Set();
|
|
1111
1110
|
this.app = app;
|
|
1112
|
-
this._scene = new
|
|
1111
|
+
this._scene = new webgpu.Scene();
|
|
1113
1112
|
}
|
|
1114
1113
|
init() {
|
|
1115
1114
|
}
|
|
@@ -1124,7 +1123,7 @@ class World {
|
|
|
1124
1123
|
});
|
|
1125
1124
|
this.actors.clear();
|
|
1126
1125
|
this.scene.traverse((child) => {
|
|
1127
|
-
if (child instanceof
|
|
1126
|
+
if (child instanceof webgpu.Mesh) {
|
|
1128
1127
|
ThreeObjectLibrary.disposeMeshResource(child);
|
|
1129
1128
|
}
|
|
1130
1129
|
});
|
|
@@ -1147,13 +1146,13 @@ const DefaultToneMappingParams = {
|
|
|
1147
1146
|
toneMapping: 'AgX',
|
|
1148
1147
|
};
|
|
1149
1148
|
const ToneMappingOptions = new Map([
|
|
1150
|
-
["None",
|
|
1151
|
-
["Linear",
|
|
1152
|
-
["Reinhard",
|
|
1153
|
-
["Cineon",
|
|
1154
|
-
["ACESFilmic",
|
|
1155
|
-
["AgX",
|
|
1156
|
-
["Neutral",
|
|
1149
|
+
["None", webgpu.NoToneMapping],
|
|
1150
|
+
["Linear", webgpu.LinearToneMapping],
|
|
1151
|
+
["Reinhard", webgpu.ReinhardToneMapping],
|
|
1152
|
+
["Cineon", webgpu.CineonToneMapping],
|
|
1153
|
+
["ACESFilmic", webgpu.ACESFilmicToneMapping],
|
|
1154
|
+
["AgX", webgpu.AgXToneMapping],
|
|
1155
|
+
["Neutral", webgpu.NeutralToneMapping]
|
|
1157
1156
|
]);
|
|
1158
1157
|
|
|
1159
1158
|
class WebGPUPostProcessFactory {
|
|
@@ -1755,8 +1754,8 @@ class Orbital extends Pawn {
|
|
|
1755
1754
|
focusTo(targetPos, targetQuat, distance, time, onGoing = null, onFinished = null) {
|
|
1756
1755
|
this.stopFocusing();
|
|
1757
1756
|
let finalQuat = null;
|
|
1758
|
-
if (targetQuat instanceof
|
|
1759
|
-
finalQuat = new
|
|
1757
|
+
if (targetQuat instanceof webgpu.Euler) {
|
|
1758
|
+
finalQuat = new webgpu.Quaternion().setFromEuler(targetQuat);
|
|
1760
1759
|
}
|
|
1761
1760
|
else {
|
|
1762
1761
|
finalQuat = targetQuat;
|
|
@@ -1765,20 +1764,20 @@ class Orbital extends Pawn {
|
|
|
1765
1764
|
finalQuat = this.controller.camera.quaternion;
|
|
1766
1765
|
}
|
|
1767
1766
|
finalQuat.normalize();
|
|
1768
|
-
let dir = new
|
|
1767
|
+
let dir = new webgpu.Vector3(0, 0, 1);
|
|
1769
1768
|
dir.applyQuaternion(finalQuat).multiplyScalar(-1);
|
|
1770
1769
|
dir.normalize();
|
|
1771
1770
|
// quat
|
|
1772
1771
|
// let startQuat = this.camera.quaternion.clone();
|
|
1773
1772
|
// position
|
|
1774
1773
|
let startPos = this.camera.position.clone();
|
|
1775
|
-
let endPos = new
|
|
1776
|
-
let posDir = new
|
|
1774
|
+
let endPos = new webgpu.Vector3(targetPos.x + dir.x * distance * -1, targetPos.y + dir.y * distance * -1, targetPos.z + dir.z * distance * -1);
|
|
1775
|
+
let posDir = new webgpu.Vector3().subVectors(endPos, startPos);
|
|
1777
1776
|
let movingLength = posDir.length();
|
|
1778
1777
|
posDir.normalize();
|
|
1779
1778
|
// target
|
|
1780
1779
|
let startTarget = this.control.target.clone();
|
|
1781
|
-
let targetDir = new
|
|
1780
|
+
let targetDir = new webgpu.Vector3().subVectors(targetPos, startTarget);
|
|
1782
1781
|
let targetDistance = targetDir.length();
|
|
1783
1782
|
targetDir.normalize();
|
|
1784
1783
|
// start animation
|
|
@@ -1793,8 +1792,8 @@ class Orbital extends Pawn {
|
|
|
1793
1792
|
alpha: 1,
|
|
1794
1793
|
onUpdate: () => {
|
|
1795
1794
|
let alpha = obj.alpha;
|
|
1796
|
-
let camPos = new
|
|
1797
|
-
let targetPos = new
|
|
1795
|
+
let camPos = new webgpu.Vector3(startPos.x + posDir.x * alpha * movingLength, startPos.y + posDir.y * alpha * movingLength, startPos.z + posDir.z * alpha * movingLength);
|
|
1796
|
+
let targetPos = new webgpu.Vector3(startTarget.x + targetDir.x * alpha * targetDistance, startTarget.y + targetDir.y * alpha * targetDistance, startTarget.z + targetDir.z * alpha * targetDistance);
|
|
1798
1797
|
_this.control.object.position.copy(camPos);
|
|
1799
1798
|
_this.control.target.copy(targetPos);
|
|
1800
1799
|
_this.control.update();
|
|
@@ -1849,17 +1848,17 @@ class Controller {
|
|
|
1849
1848
|
this.onPointerLeave = (event) => { this.onPointerLeaveEvent(event); };
|
|
1850
1849
|
this.onPointerUp = (event) => { this.onPointerUpEvent(event); };
|
|
1851
1850
|
this.onPointerDown = (event) => { this.onPointerDownEvent(event); };
|
|
1852
|
-
this.pointerPosition = new
|
|
1851
|
+
this.pointerPosition = new webgpu.Vector2();
|
|
1853
1852
|
this.doubleClickDelay = 250; // 双击判定时间间隔(毫秒)
|
|
1854
1853
|
this.leftClickTimer = null;
|
|
1855
|
-
this.pointerLeftDownPosition = new
|
|
1854
|
+
this.pointerLeftDownPosition = new webgpu.Vector2();
|
|
1856
1855
|
this.hoveringComponent = null;
|
|
1857
1856
|
this._pointButtonIsDown = new Set();
|
|
1858
1857
|
this._onClickNothingDelegate = new Delegate();
|
|
1859
1858
|
this.app = app;
|
|
1860
1859
|
this._pawn = new Orbital(this);
|
|
1861
1860
|
this.pawn.possess();
|
|
1862
|
-
this.raycaster = new
|
|
1861
|
+
this.raycaster = new webgpu.Raycaster();
|
|
1863
1862
|
if (!this.viewPort.canvas) {
|
|
1864
1863
|
throw Error("canvas is null");
|
|
1865
1864
|
}
|
|
@@ -1898,7 +1897,7 @@ class Controller {
|
|
|
1898
1897
|
const canvasRect = this.viewPort.canvas.getBoundingClientRect();
|
|
1899
1898
|
const offsetX = canvasRect.left;
|
|
1900
1899
|
const offsetY = canvasRect.top;
|
|
1901
|
-
const pointer = new
|
|
1900
|
+
const pointer = new webgpu.Vector2(((event.clientX - offsetX) / this.viewPort.canvas.clientWidth) * 2 - 1, 1 - ((event.clientY - offsetY) / this.viewPort.canvas.clientHeight) * 2);
|
|
1902
1901
|
this.pointerPosition = pointer;
|
|
1903
1902
|
if (this._pointButtonIsDown.size > 0) {
|
|
1904
1903
|
return;
|
|
@@ -1923,7 +1922,7 @@ class Controller {
|
|
|
1923
1922
|
onPointerUpEvent(event) {
|
|
1924
1923
|
this._pointButtonIsDown.delete(event.button);
|
|
1925
1924
|
if (event.button === 0) {
|
|
1926
|
-
const pointerOffset = new
|
|
1925
|
+
const pointerOffset = new webgpu.Vector2().subVectors(this.pointerLeftDownPosition, this.pointerPosition).length();
|
|
1927
1926
|
if (pointerOffset > 0.005) {
|
|
1928
1927
|
if (this.leftClickTimer) {
|
|
1929
1928
|
window.clearTimeout(this.leftClickTimer);
|
|
@@ -1988,7 +1987,7 @@ class Controller {
|
|
|
1988
1987
|
return this.getHitResultFromScreenPoint(this.pointerPosition.x, this.pointerPosition.y);
|
|
1989
1988
|
}
|
|
1990
1989
|
getHitResultFromScreenPoint(x, y) {
|
|
1991
|
-
this.raycaster.setFromCamera(new
|
|
1990
|
+
this.raycaster.setFromCamera(new webgpu.Vector2(x, y), this.camera);
|
|
1992
1991
|
let out = this.raycaster.intersectObjects(this.world.scene.children, true);
|
|
1993
1992
|
for (let i = 0; i < out.length; i++) {
|
|
1994
1993
|
if (out[i].object.userData["rayIgnored"]) {
|
|
@@ -2007,10 +2006,10 @@ class CameraFactory {
|
|
|
2007
2006
|
static createCamera(param) {
|
|
2008
2007
|
let cam = null;
|
|
2009
2008
|
if ("fov" in param.param && "aspect" in param.param) {
|
|
2010
|
-
cam = new
|
|
2009
|
+
cam = new webgpu.PerspectiveCamera(param.param.fov, param.param.aspect, param.near, param.far);
|
|
2011
2010
|
}
|
|
2012
2011
|
if ("left" in param.param && "right" in param.param && "top" in param.param && "bottom" in param.param) {
|
|
2013
|
-
cam = new
|
|
2012
|
+
cam = new webgpu.OrthographicCamera(param.param.left, param.param.right, param.param.top, param.param.bottom, param.near, param.far);
|
|
2014
2013
|
}
|
|
2015
2014
|
if (!cam) {
|
|
2016
2015
|
console.error("create camera failed");
|
|
@@ -2021,7 +2020,7 @@ class CameraFactory {
|
|
|
2021
2020
|
}
|
|
2022
2021
|
static updataCamera(param, camera) {
|
|
2023
2022
|
if ("fov" in param.param && "aspect" in param.param) {
|
|
2024
|
-
if (camera instanceof
|
|
2023
|
+
if (camera instanceof webgpu.PerspectiveCamera) {
|
|
2025
2024
|
camera.near = param.near;
|
|
2026
2025
|
camera.far = param.far;
|
|
2027
2026
|
camera.fov = param.param.fov;
|
|
@@ -2029,11 +2028,11 @@ class CameraFactory {
|
|
|
2029
2028
|
return camera;
|
|
2030
2029
|
}
|
|
2031
2030
|
else {
|
|
2032
|
-
return new
|
|
2031
|
+
return new webgpu.PerspectiveCamera(param.param.fov, param.param.aspect, param.near, param.far);
|
|
2033
2032
|
}
|
|
2034
2033
|
}
|
|
2035
2034
|
if ("left" in param.param && "right" in param.param && "top" in param.param && "bottom" in param.param) {
|
|
2036
|
-
if (camera instanceof
|
|
2035
|
+
if (camera instanceof webgpu.OrthographicCamera) {
|
|
2037
2036
|
camera.near = param.near;
|
|
2038
2037
|
camera.far = param.far;
|
|
2039
2038
|
camera.left = param.param.left;
|
|
@@ -2043,16 +2042,13 @@ class CameraFactory {
|
|
|
2043
2042
|
return camera;
|
|
2044
2043
|
}
|
|
2045
2044
|
else {
|
|
2046
|
-
return new
|
|
2045
|
+
return new webgpu.OrthographicCamera(param.param.left, param.param.right, param.param.top, param.param.bottom, param.near, param.far);
|
|
2047
2046
|
}
|
|
2048
2047
|
}
|
|
2049
2048
|
return camera;
|
|
2050
2049
|
}
|
|
2051
2050
|
}
|
|
2052
2051
|
|
|
2053
|
-
const DefaultRenderParam = {
|
|
2054
|
-
antialias: true,
|
|
2055
|
-
};
|
|
2056
2052
|
const DefaultCameraParam = {
|
|
2057
2053
|
near: 0.1,
|
|
2058
2054
|
far: 1000,
|
|
@@ -2061,11 +2057,16 @@ const DefaultCameraParam = {
|
|
|
2061
2057
|
aspect: 1,
|
|
2062
2058
|
}
|
|
2063
2059
|
};
|
|
2060
|
+
|
|
2061
|
+
const DefaultRenderParam = {
|
|
2062
|
+
antialias: true,
|
|
2063
|
+
};
|
|
2064
2064
|
const DefaultAppParam = {
|
|
2065
2065
|
renderParam: DefaultRenderParam,
|
|
2066
2066
|
cameraParam: DefaultCameraParam,
|
|
2067
2067
|
postProcessParam: DefaultPostProcessParam,
|
|
2068
2068
|
};
|
|
2069
|
+
|
|
2069
2070
|
class ThreeJsApp {
|
|
2070
2071
|
get camera() {
|
|
2071
2072
|
return this._camera;
|
|
@@ -2103,7 +2104,7 @@ class ThreeJsApp {
|
|
|
2103
2104
|
this._appParam.cameraParam = appParam.cameraParam ? appParam.cameraParam : DefaultCameraParam;
|
|
2104
2105
|
this._appParam.renderParam = appParam.renderParam ? appParam.renderParam : DefaultRenderParam;
|
|
2105
2106
|
this._appParam.postProcessParam = appParam.postProcessParam ? appParam.postProcessParam : DefaultPostProcessParam;
|
|
2106
|
-
this._clock = new
|
|
2107
|
+
this._clock = new webgpu.Clock();
|
|
2107
2108
|
this._camera = CameraFactory.createCamera(this._appParam.cameraParam);
|
|
2108
2109
|
this._world = new this.worldClass(this);
|
|
2109
2110
|
this._viewport = new this.viewportClass(this, elementId, this._appParam.renderParam, this._appParam.postProcessParam);
|
|
@@ -2139,7 +2140,7 @@ class ThreeJsApp {
|
|
|
2139
2140
|
this.viewport.markRenderStateDirty();
|
|
2140
2141
|
}
|
|
2141
2142
|
onWindowResize(width, height) {
|
|
2142
|
-
if (this.camera instanceof
|
|
2143
|
+
if (this.camera instanceof webgpu.PerspectiveCamera) {
|
|
2143
2144
|
this.camera.aspect = width / height;
|
|
2144
2145
|
}
|
|
2145
2146
|
// if(this.camera instanceof OrthographicCamera)
|
|
@@ -2214,7 +2215,7 @@ class Actor extends BaseObject {
|
|
|
2214
2215
|
this.constructRootComponent(myThreeObject);
|
|
2215
2216
|
}
|
|
2216
2217
|
constructRootComponent(myThreeObject = null) {
|
|
2217
|
-
let tObject = myThreeObject ? myThreeObject : new
|
|
2218
|
+
let tObject = myThreeObject ? myThreeObject : new webgpu.Group();
|
|
2218
2219
|
if (tObject.isMesh) {
|
|
2219
2220
|
let mesh = tObject;
|
|
2220
2221
|
this._rootComponent = new MeshComponent(mesh);
|
|
@@ -2226,7 +2227,7 @@ class Actor extends BaseObject {
|
|
|
2226
2227
|
}
|
|
2227
2228
|
}
|
|
2228
2229
|
getBoundsCenterPosition(bInWorldSpace = true) {
|
|
2229
|
-
let ret = new
|
|
2230
|
+
let ret = new webgpu.Vector3();
|
|
2230
2231
|
this.getBounds().getCenter(ret);
|
|
2231
2232
|
if (!bInWorldSpace) {
|
|
2232
2233
|
return ret.sub(this.getPosition());
|
|
@@ -2236,7 +2237,7 @@ class Actor extends BaseObject {
|
|
|
2236
2237
|
}
|
|
2237
2238
|
}
|
|
2238
2239
|
getBoundsTopCenterPosition(bInWorldSpace = true) {
|
|
2239
|
-
let ret = new
|
|
2240
|
+
let ret = new webgpu.Vector3();
|
|
2240
2241
|
let bounds = this.rootComponent.getBounds();
|
|
2241
2242
|
bounds.getCenter(ret);
|
|
2242
2243
|
ret.y = bounds.max.y;
|
|
@@ -2248,7 +2249,7 @@ class Actor extends BaseObject {
|
|
|
2248
2249
|
}
|
|
2249
2250
|
}
|
|
2250
2251
|
getBoundsBottomCenterPosition(bInWorldSpace = true) {
|
|
2251
|
-
let ret = new
|
|
2252
|
+
let ret = new webgpu.Vector3();
|
|
2252
2253
|
let bounds = this.getBounds();
|
|
2253
2254
|
bounds.getCenter(ret);
|
|
2254
2255
|
ret.y = bounds.min.y;
|
|
@@ -2580,7 +2581,7 @@ class DirectionalLightComponent extends LightComponent {
|
|
|
2580
2581
|
this.threeObject.castShadow = value;
|
|
2581
2582
|
}
|
|
2582
2583
|
constructor(color = 0xffffff, intensity = 10) {
|
|
2583
|
-
let obj = new
|
|
2584
|
+
let obj = new webgpu.DirectionalLight(color, intensity);
|
|
2584
2585
|
super(obj);
|
|
2585
2586
|
this.obj = obj;
|
|
2586
2587
|
obj.castShadow = true;
|
|
@@ -2619,13 +2620,13 @@ class DirectionalLightActor extends Actor {
|
|
|
2619
2620
|
}
|
|
2620
2621
|
|
|
2621
2622
|
class BoxComponent extends MeshComponent {
|
|
2622
|
-
constructor(width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new
|
|
2623
|
-
super(new
|
|
2623
|
+
constructor(width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new webgpu.MeshStandardMaterial()) {
|
|
2624
|
+
super(new webgpu.BoxGeometry(width, height, depth, widthSegments, heightSegments, depthSegments), material);
|
|
2624
2625
|
}
|
|
2625
2626
|
}
|
|
2626
2627
|
|
|
2627
2628
|
class BoxActor extends Actor {
|
|
2628
|
-
constructor(width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new
|
|
2629
|
+
constructor(width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new webgpu.MeshBasicMaterial()) {
|
|
2629
2630
|
super();
|
|
2630
2631
|
this.addComponent(new BoxComponent(width, height, depth, widthSegments, heightSegments, depthSegments, material));
|
|
2631
2632
|
}
|
|
@@ -2633,7 +2634,7 @@ class BoxActor extends Actor {
|
|
|
2633
2634
|
|
|
2634
2635
|
class PlaneComponent extends MeshComponent {
|
|
2635
2636
|
constructor(width, height, material, widthSegments = 1, heightSegments = 1) {
|
|
2636
|
-
super(new
|
|
2637
|
+
super(new webgpu.PlaneGeometry(width, height, widthSegments, heightSegments), material);
|
|
2637
2638
|
}
|
|
2638
2639
|
}
|
|
2639
2640
|
|
|
@@ -2641,7 +2642,7 @@ class PlaneActor extends Actor {
|
|
|
2641
2642
|
get planeComponent() {
|
|
2642
2643
|
return this._planeComponent;
|
|
2643
2644
|
}
|
|
2644
|
-
constructor(width, height, material = new
|
|
2645
|
+
constructor(width, height, material = new webgpu.MeshBasicMaterial(), widthSegments = 1, heightSegments = 1) {
|
|
2645
2646
|
super();
|
|
2646
2647
|
this._planeComponent = new PlaneComponent(width, height, material, widthSegments, heightSegments);
|
|
2647
2648
|
this._planeComponent.setRotation(Math.PI * 0.5 * -1, 0, 0);
|
|
@@ -2692,8 +2693,8 @@ const DefaultSSRParam = {
|
|
|
2692
2693
|
};
|
|
2693
2694
|
|
|
2694
2695
|
class SphereComponent extends MeshComponent {
|
|
2695
|
-
constructor(radius, material = new
|
|
2696
|
-
super(new
|
|
2696
|
+
constructor(radius, material = new webgpu.MeshBasicMaterial(), widthSegments = 32, heightSegments = 16) {
|
|
2697
|
+
super(new webgpu.SphereGeometry(radius, widthSegments, heightSegments), material);
|
|
2697
2698
|
}
|
|
2698
2699
|
}
|
|
2699
2700
|
|
|
@@ -2707,7 +2708,7 @@ class LabelComponent extends SceneComponent {
|
|
|
2707
2708
|
this.obj.userData["LYObject"] = this;
|
|
2708
2709
|
}
|
|
2709
2710
|
}
|
|
2710
|
-
constructor(domElement, center = new
|
|
2711
|
+
constructor(domElement, center = new webgpu.Vector2(0.5, 1)) {
|
|
2711
2712
|
let obj = new CSS2DRenderer_js.CSS2DObject(domElement);
|
|
2712
2713
|
super(obj);
|
|
2713
2714
|
this.obj = obj;
|
|
@@ -2757,7 +2758,7 @@ class TransformGizmo extends Pawn {
|
|
|
2757
2758
|
constructor(controller) {
|
|
2758
2759
|
super(controller);
|
|
2759
2760
|
this._control = null;
|
|
2760
|
-
this.helperObject = new
|
|
2761
|
+
this.helperObject = new webgpu.Object3D();
|
|
2761
2762
|
this.targets = [];
|
|
2762
2763
|
this.primaryTarget = null;
|
|
2763
2764
|
this.targetMatrixMap = new Map();
|
|
@@ -2831,7 +2832,7 @@ class TransformGizmo extends Pawn {
|
|
|
2831
2832
|
if (tar !== this.primaryTarget) {
|
|
2832
2833
|
let t = this.targetMatrixMap.get(tar);
|
|
2833
2834
|
if (t) {
|
|
2834
|
-
let TB2 = new
|
|
2835
|
+
let TB2 = new webgpu.Matrix4().multiplyMatrices(TA2, t); // B
|
|
2835
2836
|
tar.onTransforming(TB2);
|
|
2836
2837
|
}
|
|
2837
2838
|
}
|
|
@@ -2907,7 +2908,6 @@ exports.BoxComponent = BoxComponent;
|
|
|
2907
2908
|
exports.Controller = Controller;
|
|
2908
2909
|
exports.DefaultAppParam = DefaultAppParam;
|
|
2909
2910
|
exports.DefaultBloomParam = DefaultBloomParam;
|
|
2910
|
-
exports.DefaultCameraParam = DefaultCameraParam;
|
|
2911
2911
|
exports.DefaultDOFParam = DefaultDOFParam;
|
|
2912
2912
|
exports.DefaultDenoiseParam = DefaultDenoiseParam;
|
|
2913
2913
|
exports.DefaultGTAOParam = DefaultGTAOParam;
|