lythreeframe 1.0.22 → 1.0.24

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.
Files changed (39) hide show
  1. package/dist/bundle.cjs.js +217 -141
  2. package/dist/bundle.esm.js +112 -39
  3. package/dist/index.d.ts +11 -7
  4. package/dist/lythreeframe/AssetManagement/AssetManager.d.ts +1 -1
  5. package/dist/lythreeframe/AssetManagement/AssetPointer/AssetPointer.d.ts +1 -1
  6. package/dist/lythreeframe/Factory/CameraFactory.d.ts +2 -2
  7. package/dist/lythreeframe/Frame/Controller.d.ts +1 -1
  8. package/dist/lythreeframe/Frame/World.d.ts +1 -1
  9. package/dist/lythreeframe/Geometry/PlaneGeometry.d.ts +1 -1
  10. package/dist/lythreeframe/Geometry/TriangleGeometry.d.ts +1 -1
  11. package/dist/lythreeframe/Library/Math.d.ts +5 -5
  12. package/dist/lythreeframe/Library/ResourceLibrary.d.ts +1 -1
  13. package/dist/lythreeframe/Object/Actor.d.ts +5 -5
  14. package/dist/lythreeframe/Object/Actors/Light/DirectionalLightActor.d.ts +3 -2
  15. package/dist/lythreeframe/Object/Actors/Shape/BoxActor.d.ts +1 -1
  16. package/dist/lythreeframe/Object/Actors/Shape/PlaneActor.d.ts +1 -1
  17. package/dist/lythreeframe/Object/Actors/Sky/SkyActor.d.ts +8 -0
  18. package/dist/lythreeframe/Object/Components/2D/2DComponent.d.ts +1 -2
  19. package/dist/lythreeframe/Object/Components/Camera/CameraComponent.d.ts +1 -1
  20. package/dist/lythreeframe/Object/Components/Component.d.ts +1 -1
  21. package/dist/lythreeframe/Object/Components/Light/DirectionalLight/DirectionalLightComponent.d.ts +1 -1
  22. package/dist/lythreeframe/Object/Components/Light/LightComponent.d.ts +1 -1
  23. package/dist/lythreeframe/Object/Components/Mesh/InstanceMesh/InstanceMeshComponent.d.ts +1 -1
  24. package/dist/lythreeframe/Object/Components/Mesh/InstanceMesh/MultiInstanceMeshComponent.d.ts +1 -1
  25. package/dist/lythreeframe/Object/Components/Mesh/MeshComponent.d.ts +6 -7
  26. package/dist/lythreeframe/Object/Components/Mesh/Shape/BoxComponent.d.ts +1 -1
  27. package/dist/lythreeframe/Object/Components/Mesh/Shape/PlaneComponent.d.ts +1 -1
  28. package/dist/lythreeframe/Object/Components/Mesh/Shape/SphereComponent.d.ts +1 -2
  29. package/dist/lythreeframe/Object/Components/Mesh/Sprite/SpriteComponent.d.ts +1 -1
  30. package/dist/lythreeframe/Object/Components/SceneComponent.d.ts +13 -13
  31. package/dist/lythreeframe/Object/Components/Sky/SkyComponent.d.ts +20 -0
  32. package/dist/lythreeframe/Object/PawnV2/Oribital.d.ts +2 -2
  33. package/dist/lythreeframe/Object/PawnV2/Pawn.d.ts +2 -2
  34. package/dist/lythreeframe/Object/PawnV2/TransformControl.d.ts +1 -1
  35. package/dist/lythreeframe/PostProcess/Param/Outline.d.ts +1 -1
  36. package/dist/lythreeframe/PostProcess/Param/ToneMapping.d.ts +1 -1
  37. package/dist/lythreeframe/PostProcess/WebGPUPostProcessFactory.d.ts +1 -1
  38. package/dist/lythreeframe/ThreeJsApp.d.ts +1 -1
  39. package/package.json +5 -5
@@ -1,9 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var three = require('three');
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');
@@ -15,6 +14,7 @@ var MotionBlur_js = require('three/examples/jsm/tsl/display/MotionBlur.js');
15
14
  var FXAANode_js = require('three/examples/jsm/tsl/display/FXAANode.js');
16
15
  var SMAANode_js = require('three/examples/jsm/tsl/display/SMAANode.js');
17
16
  var gsap = require('gsap');
17
+ var SkyMesh_js = require('three/examples/jsm/objects/SkyMesh.js');
18
18
  var CSS2DRenderer_js = require('three/examples/jsm/renderers/CSS2DRenderer.js');
19
19
  var PointerLockControls = require('three/examples/jsm/controls/PointerLockControls');
20
20
  var TransformControls_js = require('three/examples/jsm/controls/TransformControls.js');
@@ -47,7 +47,7 @@ class BaseObject {
47
47
  get uuid() {
48
48
  return this._uuid;
49
49
  }
50
- constructor(uuid = three.MathUtils.generateUUID()) {
50
+ constructor(uuid = webgpu.MathUtils.generateUUID()) {
51
51
  this.bCanTick = false;
52
52
  this.bCanTick = false;
53
53
  this._uuid = uuid;
@@ -132,7 +132,7 @@ class SceneComponent extends Component {
132
132
  this._name = "SceneComponent";
133
133
  }
134
134
  createDefaultThreeObject() {
135
- this.threeObject = new three.Group();
135
+ this.threeObject = new webgpu.Group();
136
136
  }
137
137
  get isVisible() {
138
138
  if (!this.threeObject) {
@@ -160,19 +160,19 @@ class SceneComponent extends Component {
160
160
  });
161
161
  }
162
162
  getBoundsCenterPositionWS() {
163
- let ret = new three.Vector3();
163
+ let ret = new webgpu.Vector3();
164
164
  this.getBounds().getCenter(ret);
165
165
  return this.getWorldPosition();
166
166
  }
167
167
  getBoundsTopCenterPositionWS() {
168
- let ret = new three.Vector3();
168
+ let ret = new webgpu.Vector3();
169
169
  let bounds = this.getBounds();
170
170
  bounds.getCenter(ret);
171
171
  ret.y = bounds.max.y;
172
172
  return ret;
173
173
  }
174
174
  getBoundsBottomCenterPositionWS() {
175
- let ret = new three.Vector3();
175
+ let ret = new webgpu.Vector3();
176
176
  let bounds = this.getBounds();
177
177
  bounds.getCenter(ret);
178
178
  ret.y = bounds.min.y;
@@ -182,7 +182,7 @@ class SceneComponent extends Component {
182
182
  if (!this.threeObject) {
183
183
  throw Error("threeObject is invalid");
184
184
  }
185
- let ret = new three.Box3();
185
+ let ret = new webgpu.Box3();
186
186
  ret.setFromObject(this.threeObject, false);
187
187
  if (ret.isEmpty()) {
188
188
  ret.min = ret.max = this.getWorldPosition();
@@ -259,9 +259,9 @@ class SceneComponent extends Component {
259
259
  return this.threeObject.position.clone();
260
260
  }
261
261
  else {
262
- const position = new three.Vector3();
263
- const quaternion = new three.Quaternion();
264
- const scale = new three.Vector3();
262
+ const position = new webgpu.Vector3();
263
+ const quaternion = new webgpu.Quaternion();
264
+ const scale = new webgpu.Vector3();
265
265
  this.threeObject.matrix.decompose(position, quaternion, scale);
266
266
  return position;
267
267
  }
@@ -271,14 +271,14 @@ class SceneComponent extends Component {
271
271
  throw Error("threeObject is invalid");
272
272
  }
273
273
  let newPosition = null;
274
- if (args.length === 1 && args[0] instanceof three.Vector3) {
275
- newPosition = new three.Vector3().copy(args[0]);
274
+ if (args.length === 1 && args[0] instanceof webgpu.Vector3) {
275
+ newPosition = new webgpu.Vector3().copy(args[0]);
276
276
  }
277
277
  else if (args.length === 3 &&
278
278
  typeof args[0] === "number" &&
279
279
  typeof args[1] === "number" &&
280
280
  typeof args[2] === "number") {
281
- newPosition = new three.Vector3(args[0], args[1], args[2]);
281
+ newPosition = new webgpu.Vector3(args[0], args[1], args[2]);
282
282
  }
283
283
  if (!newPosition) {
284
284
  return;
@@ -302,11 +302,11 @@ class SceneComponent extends Component {
302
302
  return this.threeObject.rotation.clone();
303
303
  }
304
304
  else {
305
- const position = new three.Vector3();
306
- const quaternion = new three.Quaternion();
307
- const scale = new three.Vector3();
305
+ const position = new webgpu.Vector3();
306
+ const quaternion = new webgpu.Quaternion();
307
+ const scale = new webgpu.Vector3();
308
308
  this.threeObject.matrix.decompose(position, quaternion, scale);
309
- return new three.Euler().setFromQuaternion(quaternion);
309
+ return new webgpu.Euler().setFromQuaternion(quaternion);
310
310
  }
311
311
  }
312
312
  setRotation(...args) {
@@ -314,11 +314,11 @@ class SceneComponent extends Component {
314
314
  throw Error("threeObject is invalid");
315
315
  }
316
316
  let newRotation = null;
317
- if (args[0] instanceof three.Euler) {
318
- newRotation = new three.Euler().copy(args[0]);
317
+ if (args[0] instanceof webgpu.Euler) {
318
+ newRotation = new webgpu.Euler().copy(args[0]);
319
319
  }
320
320
  if (typeof (args[0]) === "number" && typeof (args[1]) === "number" && typeof (args[2]) === "number") {
321
- newRotation = new three.Euler(args[0], args[1], args[2]);
321
+ newRotation = new webgpu.Euler(args[0], args[1], args[2]);
322
322
  }
323
323
  if (!newRotation) {
324
324
  return;
@@ -339,9 +339,9 @@ class SceneComponent extends Component {
339
339
  return this.threeObject.quaternion.clone();
340
340
  }
341
341
  else {
342
- const position = new three.Vector3();
343
- const quaternion = new three.Quaternion();
344
- const scale = new three.Vector3();
342
+ const position = new webgpu.Vector3();
343
+ const quaternion = new webgpu.Quaternion();
344
+ const scale = new webgpu.Vector3();
345
345
  this.threeObject.matrix.decompose(position, quaternion, scale);
346
346
  return quaternion;
347
347
  }
@@ -351,11 +351,11 @@ class SceneComponent extends Component {
351
351
  throw Error("threeObject is invalid");
352
352
  }
353
353
  let newQuat = null;
354
- if (args[0] instanceof three.Quaternion) {
355
- newQuat = new three.Quaternion().copy(args[0]);
354
+ if (args[0] instanceof webgpu.Quaternion) {
355
+ newQuat = new webgpu.Quaternion().copy(args[0]);
356
356
  }
357
357
  if (typeof args[0] === "number" && typeof args[1] === "number" && typeof args[2] === "number" && typeof args[3] === "number") {
358
- newQuat = new three.Quaternion(args[0], args[1], args[2], args[3]);
358
+ newQuat = new webgpu.Quaternion(args[0], args[1], args[2], args[3]);
359
359
  }
360
360
  if (!newQuat) {
361
361
  console.error("setQuaternion failed,param is invalid", args);
@@ -363,9 +363,9 @@ class SceneComponent extends Component {
363
363
  }
364
364
  this.threeObject.quaternion.copy(newQuat);
365
365
  if (!this.threeObject.matrixAutoUpdate) {
366
- const position = new three.Vector3();
367
- const quaternion = new three.Quaternion();
368
- const scale = new three.Vector3();
366
+ const position = new webgpu.Vector3();
367
+ const quaternion = new webgpu.Quaternion();
368
+ const scale = new webgpu.Vector3();
369
369
  this.threeObject.matrix.decompose(position, quaternion, scale);
370
370
  this.threeObject.matrix.compose(position, newQuat, scale);
371
371
  }
@@ -384,9 +384,9 @@ class SceneComponent extends Component {
384
384
  return this.threeObject.scale.clone();
385
385
  }
386
386
  else {
387
- const position = new three.Vector3();
388
- const quaternion = new three.Quaternion();
389
- const scale = new three.Vector3();
387
+ const position = new webgpu.Vector3();
388
+ const quaternion = new webgpu.Quaternion();
389
+ const scale = new webgpu.Vector3();
390
390
  this.threeObject.matrix.decompose(position, quaternion, scale);
391
391
  return scale;
392
392
  }
@@ -396,11 +396,11 @@ class SceneComponent extends Component {
396
396
  throw Error("threeObject is invalid");
397
397
  }
398
398
  let newScale = null;
399
- if (args[0] instanceof three.Vector3) {
400
- newScale = new three.Vector3().copy(args[0]);
399
+ if (args[0] instanceof webgpu.Vector3) {
400
+ newScale = new webgpu.Vector3().copy(args[0]);
401
401
  }
402
402
  if (typeof (args[0]) === "number" && typeof (args[1]) === "number" && typeof (args[2]) === "number") {
403
- newScale = new three.Vector3(args[0], args[1], args[2]);
403
+ newScale = new webgpu.Vector3(args[0], args[1], args[2]);
404
404
  }
405
405
  if (!newScale) {
406
406
  return;
@@ -444,7 +444,7 @@ class SceneComponent extends Component {
444
444
  if (!this.threeObject) {
445
445
  throw Error("threeObject is invalid");
446
446
  }
447
- let location = new three.Vector3();
447
+ let location = new webgpu.Vector3();
448
448
  this.threeObject.getWorldPosition(location);
449
449
  return location;
450
450
  }
@@ -453,16 +453,16 @@ class SceneComponent extends Component {
453
453
  if (!this.threeObject) {
454
454
  throw Error("threeObject is invalid");
455
455
  }
456
- let rotation = new three.Quaternion();
456
+ let rotation = new webgpu.Quaternion();
457
457
  this.threeObject.getWorldQuaternion(rotation);
458
- return new three.Euler().setFromQuaternion(rotation);
458
+ return new webgpu.Euler().setFromQuaternion(rotation);
459
459
  }
460
460
  // // rotation(quat)
461
461
  getWorldQuaternion() {
462
462
  if (!this.threeObject) {
463
463
  throw Error("threeObject is invalid");
464
464
  }
465
- let rotation = new three.Quaternion();
465
+ let rotation = new webgpu.Quaternion();
466
466
  this.threeObject.getWorldQuaternion(rotation);
467
467
  return rotation;
468
468
  }
@@ -471,7 +471,7 @@ class SceneComponent extends Component {
471
471
  if (!this.threeObject) {
472
472
  throw Error("threeObject is invalid");
473
473
  }
474
- let scale = new three.Vector3();
474
+ let scale = new webgpu.Vector3();
475
475
  this.threeObject.getWorldScale(scale);
476
476
  return scale;
477
477
  }
@@ -492,7 +492,7 @@ class SceneComponent extends Component {
492
492
  // 计算父对象的逆世界矩阵
493
493
  const parentInverseWorldMatrix = this.threeObject.parent.matrixWorld.clone().invert();
494
494
  // 计算物体的本地矩阵
495
- const cLocalMatrix = new three.Matrix4().multiplyMatrices(parentInverseWorldMatrix, newMatrix);
495
+ const cLocalMatrix = new webgpu.Matrix4().multiplyMatrices(parentInverseWorldMatrix, newMatrix);
496
496
  // 更新物体的本地矩阵
497
497
  this.setMatrix(cLocalMatrix);
498
498
  // this.threeObject.matrix.copy(cLocalMatrix);
@@ -516,7 +516,7 @@ class SceneComponent extends Component {
516
516
  if (!this.threeObject) {
517
517
  throw Error("threeObject is invalid");
518
518
  }
519
- let ret = new three.Vector3();
519
+ let ret = new webgpu.Vector3();
520
520
  this.threeObject.getWorldDirection(ret);
521
521
  return ret;
522
522
  }
@@ -524,7 +524,7 @@ class SceneComponent extends Component {
524
524
  if (!this.threeObject) {
525
525
  throw Error("threeObject is invalid");
526
526
  }
527
- let ret = new three.Vector3(0, 1, 0);
527
+ let ret = new webgpu.Vector3(0, 1, 0);
528
528
  ret.applyQuaternion(this.getWorldQuaternion());
529
529
  return ret;
530
530
  }
@@ -532,7 +532,7 @@ class SceneComponent extends Component {
532
532
  if (!this.threeObject) {
533
533
  throw Error("threeObject is invalid");
534
534
  }
535
- let ret = new three.Vector3(1, 0, 0);
535
+ let ret = new webgpu.Vector3(1, 0, 0);
536
536
  ret.applyQuaternion(this.getWorldQuaternion());
537
537
  return ret;
538
538
  }
@@ -711,12 +711,12 @@ class MeshComponent extends SceneComponent {
711
711
  }
712
712
  constructor(...args) {
713
713
  let newMesh = null;
714
- if (args[0] instanceof three.Mesh) {
714
+ if (args[0] instanceof webgpu.Mesh) {
715
715
  newMesh = args[0];
716
716
  }
717
717
  else {
718
- if (args[0] instanceof three.BufferGeometry && (args[1] instanceof three.Material || Array.isArray(args[1]))) {
719
- newMesh = new three.Mesh(args[0], args[1]);
718
+ if (args[0] instanceof webgpu.BufferGeometry && (args[1] instanceof webgpu.Material || Array.isArray(args[1]))) {
719
+ newMesh = new webgpu.Mesh(args[0], args[1]);
720
720
  }
721
721
  else {
722
722
  throw new Error('Invalid arguments for A constructor');
@@ -744,19 +744,19 @@ class MeshComponent extends SceneComponent {
744
744
  return this.threeObject ? this.threeObject.receiveShadow : false;
745
745
  }
746
746
  getBoundsCenterPosition() {
747
- let ret = new three.Vector3();
747
+ let ret = new webgpu.Vector3();
748
748
  this.getBounds().getCenter(ret);
749
749
  return ret;
750
750
  }
751
751
  getBoundsTopCenterPosition() {
752
- let ret = new three.Vector3();
752
+ let ret = new webgpu.Vector3();
753
753
  let bounds = this.getBounds();
754
754
  bounds.getCenter(ret);
755
755
  ret.y = bounds.max.y;
756
756
  return ret;
757
757
  }
758
758
  getBoundsBottomCenterPosition() {
759
- let ret = new three.Vector3();
759
+ let ret = new webgpu.Vector3();
760
760
  let bounds = this.getBounds();
761
761
  bounds.getCenter(ret);
762
762
  ret.y = bounds.min.y;
@@ -769,9 +769,9 @@ class MeshComponent extends SceneComponent {
769
769
  let assetManager = LYAssetManager.Get();
770
770
  const mats = Array.isArray(this.material) ? this.material : [this.material];
771
771
  mats.forEach((material) => {
772
- if (material instanceof three.Material) {
772
+ if (material instanceof webgpu.Material) {
773
773
  Object.entries(material).forEach(([key, value]) => {
774
- if (value instanceof three.Texture) {
774
+ if (value instanceof webgpu.Texture) {
775
775
  assetManager.releaseAsset(value);
776
776
  value = null;
777
777
  }
@@ -780,7 +780,7 @@ class MeshComponent extends SceneComponent {
780
780
  }
781
781
  });
782
782
  this.material = [];
783
- if (this.geometry instanceof three.BufferGeometry) {
783
+ if (this.geometry instanceof webgpu.BufferGeometry) {
784
784
  assetManager.releaseAsset(this.geometry);
785
785
  this.geometry = null;
786
786
  }
@@ -854,7 +854,7 @@ class LYAssetManager {
854
854
  constructor() {
855
855
  this.assetPointer = new Map();
856
856
  this.dracoLoader = null;
857
- this.loadingManager = new three.LoadingManager();
857
+ this.loadingManager = new webgpu.LoadingManager();
858
858
  this.gltfLoader = new Addons_js.GLTFLoader(this.loadingManager);
859
859
  }
860
860
  get LoadingManager() {
@@ -922,7 +922,7 @@ class LYAssetManager {
922
922
  textures: new Map()
923
923
  };
924
924
  gltf.scene.traverse((child) => {
925
- if (child.geometry && child.geometry instanceof three.BufferGeometry) {
925
+ if (child.geometry && child.geometry instanceof webgpu.BufferGeometry) {
926
926
  countResource(resources.geometries, child.geometry);
927
927
  }
928
928
  if (child.material) {
@@ -931,7 +931,7 @@ class LYAssetManager {
931
931
  if (mat) {
932
932
  countResource(resources.materials, mat);
933
933
  Object.entries(mat).forEach(([key, value]) => {
934
- if (value instanceof three.Texture) {
934
+ if (value instanceof webgpu.Texture) {
935
935
  countResource(resources.textures, value);
936
936
  }
937
937
  });
@@ -966,7 +966,7 @@ class LYAssetManager {
966
966
  this.addAsset(material);
967
967
  }
968
968
  Object.entries(material).forEach(([key, value]) => {
969
- if (value instanceof three.Texture) {
969
+ if (value instanceof webgpu.Texture) {
970
970
  if (!value.userData["assetPointer"]) {
971
971
  this.addAsset(value);
972
972
  }
@@ -1010,7 +1010,7 @@ class LYAssetManager {
1010
1010
  this.gltfLoader.parse(data, path, onLoadFinished);
1011
1011
  }
1012
1012
  loadFile(filepath = '', onLoadFinished) {
1013
- const loader = new three.FileLoader();
1013
+ const loader = new webgpu.FileLoader();
1014
1014
  loader.load(filepath, (data) => {
1015
1015
  onLoadFinished(data);
1016
1016
  });
@@ -1109,7 +1109,7 @@ class World {
1109
1109
  constructor(app) {
1110
1110
  this.actors = new Set();
1111
1111
  this.app = app;
1112
- this._scene = new three.Scene();
1112
+ this._scene = new webgpu.Scene();
1113
1113
  }
1114
1114
  init() {
1115
1115
  }
@@ -1124,7 +1124,7 @@ class World {
1124
1124
  });
1125
1125
  this.actors.clear();
1126
1126
  this.scene.traverse((child) => {
1127
- if (child instanceof three.Mesh) {
1127
+ if (child instanceof webgpu.Mesh) {
1128
1128
  ThreeObjectLibrary.disposeMeshResource(child);
1129
1129
  }
1130
1130
  });
@@ -1147,13 +1147,13 @@ const DefaultToneMappingParams = {
1147
1147
  toneMapping: 'AgX',
1148
1148
  };
1149
1149
  const ToneMappingOptions = new Map([
1150
- ["None", three.NoToneMapping],
1151
- ["Linear", three.LinearToneMapping],
1152
- ["Reinhard", three.ReinhardToneMapping],
1153
- ["Cineon", three.CineonToneMapping],
1154
- ["ACESFilmic", three.ACESFilmicToneMapping],
1155
- ["AgX", three.AgXToneMapping],
1156
- ["Neutral", three.NeutralToneMapping]
1150
+ ["None", webgpu.NoToneMapping],
1151
+ ["Linear", webgpu.LinearToneMapping],
1152
+ ["Reinhard", webgpu.ReinhardToneMapping],
1153
+ ["Cineon", webgpu.CineonToneMapping],
1154
+ ["ACESFilmic", webgpu.ACESFilmicToneMapping],
1155
+ ["AgX", webgpu.AgXToneMapping],
1156
+ ["Neutral", webgpu.NeutralToneMapping]
1157
1157
  ]);
1158
1158
 
1159
1159
  class WebGPUPostProcessFactory {
@@ -1755,8 +1755,8 @@ class Orbital extends Pawn {
1755
1755
  focusTo(targetPos, targetQuat, distance, time, onGoing = null, onFinished = null) {
1756
1756
  this.stopFocusing();
1757
1757
  let finalQuat = null;
1758
- if (targetQuat instanceof three.Euler) {
1759
- finalQuat = new three.Quaternion().setFromEuler(targetQuat);
1758
+ if (targetQuat instanceof webgpu.Euler) {
1759
+ finalQuat = new webgpu.Quaternion().setFromEuler(targetQuat);
1760
1760
  }
1761
1761
  else {
1762
1762
  finalQuat = targetQuat;
@@ -1765,20 +1765,20 @@ class Orbital extends Pawn {
1765
1765
  finalQuat = this.controller.camera.quaternion;
1766
1766
  }
1767
1767
  finalQuat.normalize();
1768
- let dir = new three.Vector3(0, 0, 1);
1768
+ let dir = new webgpu.Vector3(0, 0, 1);
1769
1769
  dir.applyQuaternion(finalQuat).multiplyScalar(-1);
1770
1770
  dir.normalize();
1771
1771
  // quat
1772
1772
  // let startQuat = this.camera.quaternion.clone();
1773
1773
  // position
1774
1774
  let startPos = this.camera.position.clone();
1775
- let endPos = new three.Vector3(targetPos.x + dir.x * distance * -1, targetPos.y + dir.y * distance * -1, targetPos.z + dir.z * distance * -1);
1776
- let posDir = new three.Vector3().subVectors(endPos, startPos);
1775
+ let endPos = new webgpu.Vector3(targetPos.x + dir.x * distance * -1, targetPos.y + dir.y * distance * -1, targetPos.z + dir.z * distance * -1);
1776
+ let posDir = new webgpu.Vector3().subVectors(endPos, startPos);
1777
1777
  let movingLength = posDir.length();
1778
1778
  posDir.normalize();
1779
1779
  // target
1780
1780
  let startTarget = this.control.target.clone();
1781
- let targetDir = new three.Vector3().subVectors(targetPos, startTarget);
1781
+ let targetDir = new webgpu.Vector3().subVectors(targetPos, startTarget);
1782
1782
  let targetDistance = targetDir.length();
1783
1783
  targetDir.normalize();
1784
1784
  // start animation
@@ -1793,8 +1793,8 @@ class Orbital extends Pawn {
1793
1793
  alpha: 1,
1794
1794
  onUpdate: () => {
1795
1795
  let alpha = obj.alpha;
1796
- let camPos = new three.Vector3(startPos.x + posDir.x * alpha * movingLength, startPos.y + posDir.y * alpha * movingLength, startPos.z + posDir.z * alpha * movingLength);
1797
- let targetPos = new three.Vector3(startTarget.x + targetDir.x * alpha * targetDistance, startTarget.y + targetDir.y * alpha * targetDistance, startTarget.z + targetDir.z * alpha * targetDistance);
1796
+ let camPos = new webgpu.Vector3(startPos.x + posDir.x * alpha * movingLength, startPos.y + posDir.y * alpha * movingLength, startPos.z + posDir.z * alpha * movingLength);
1797
+ let targetPos = new webgpu.Vector3(startTarget.x + targetDir.x * alpha * targetDistance, startTarget.y + targetDir.y * alpha * targetDistance, startTarget.z + targetDir.z * alpha * targetDistance);
1798
1798
  _this.control.object.position.copy(camPos);
1799
1799
  _this.control.target.copy(targetPos);
1800
1800
  _this.control.update();
@@ -1849,17 +1849,17 @@ class Controller {
1849
1849
  this.onPointerLeave = (event) => { this.onPointerLeaveEvent(event); };
1850
1850
  this.onPointerUp = (event) => { this.onPointerUpEvent(event); };
1851
1851
  this.onPointerDown = (event) => { this.onPointerDownEvent(event); };
1852
- this.pointerPosition = new three.Vector2();
1852
+ this.pointerPosition = new webgpu.Vector2();
1853
1853
  this.doubleClickDelay = 250; // 双击判定时间间隔(毫秒)
1854
1854
  this.leftClickTimer = null;
1855
- this.pointerLeftDownPosition = new three.Vector2();
1855
+ this.pointerLeftDownPosition = new webgpu.Vector2();
1856
1856
  this.hoveringComponent = null;
1857
1857
  this._pointButtonIsDown = new Set();
1858
1858
  this._onClickNothingDelegate = new Delegate();
1859
1859
  this.app = app;
1860
1860
  this._pawn = new Orbital(this);
1861
1861
  this.pawn.possess();
1862
- this.raycaster = new three.Raycaster();
1862
+ this.raycaster = new webgpu.Raycaster();
1863
1863
  if (!this.viewPort.canvas) {
1864
1864
  throw Error("canvas is null");
1865
1865
  }
@@ -1898,7 +1898,7 @@ class Controller {
1898
1898
  const canvasRect = this.viewPort.canvas.getBoundingClientRect();
1899
1899
  const offsetX = canvasRect.left;
1900
1900
  const offsetY = canvasRect.top;
1901
- const pointer = new three.Vector2(((event.clientX - offsetX) / this.viewPort.canvas.clientWidth) * 2 - 1, 1 - ((event.clientY - offsetY) / this.viewPort.canvas.clientHeight) * 2);
1901
+ const pointer = new webgpu.Vector2(((event.clientX - offsetX) / this.viewPort.canvas.clientWidth) * 2 - 1, 1 - ((event.clientY - offsetY) / this.viewPort.canvas.clientHeight) * 2);
1902
1902
  this.pointerPosition = pointer;
1903
1903
  if (this._pointButtonIsDown.size > 0) {
1904
1904
  return;
@@ -1923,7 +1923,7 @@ class Controller {
1923
1923
  onPointerUpEvent(event) {
1924
1924
  this._pointButtonIsDown.delete(event.button);
1925
1925
  if (event.button === 0) {
1926
- const pointerOffset = new three.Vector2().subVectors(this.pointerLeftDownPosition, this.pointerPosition).length();
1926
+ const pointerOffset = new webgpu.Vector2().subVectors(this.pointerLeftDownPosition, this.pointerPosition).length();
1927
1927
  if (pointerOffset > 0.005) {
1928
1928
  if (this.leftClickTimer) {
1929
1929
  window.clearTimeout(this.leftClickTimer);
@@ -1988,7 +1988,7 @@ class Controller {
1988
1988
  return this.getHitResultFromScreenPoint(this.pointerPosition.x, this.pointerPosition.y);
1989
1989
  }
1990
1990
  getHitResultFromScreenPoint(x, y) {
1991
- this.raycaster.setFromCamera(new three.Vector2(x, y), this.camera);
1991
+ this.raycaster.setFromCamera(new webgpu.Vector2(x, y), this.camera);
1992
1992
  let out = this.raycaster.intersectObjects(this.world.scene.children, true);
1993
1993
  for (let i = 0; i < out.length; i++) {
1994
1994
  if (out[i].object.userData["rayIgnored"]) {
@@ -2007,10 +2007,10 @@ class CameraFactory {
2007
2007
  static createCamera(param) {
2008
2008
  let cam = null;
2009
2009
  if ("fov" in param.param && "aspect" in param.param) {
2010
- cam = new three.PerspectiveCamera(param.param.fov, param.param.aspect, param.near, param.far);
2010
+ cam = new webgpu.PerspectiveCamera(param.param.fov, param.param.aspect, param.near, param.far);
2011
2011
  }
2012
2012
  if ("left" in param.param && "right" in param.param && "top" in param.param && "bottom" in param.param) {
2013
- cam = new three.OrthographicCamera(param.param.left, param.param.right, param.param.top, param.param.bottom, param.near, param.far);
2013
+ cam = new webgpu.OrthographicCamera(param.param.left, param.param.right, param.param.top, param.param.bottom, param.near, param.far);
2014
2014
  }
2015
2015
  if (!cam) {
2016
2016
  console.error("create camera failed");
@@ -2021,7 +2021,7 @@ class CameraFactory {
2021
2021
  }
2022
2022
  static updataCamera(param, camera) {
2023
2023
  if ("fov" in param.param && "aspect" in param.param) {
2024
- if (camera instanceof three.PerspectiveCamera) {
2024
+ if (camera instanceof webgpu.PerspectiveCamera) {
2025
2025
  camera.near = param.near;
2026
2026
  camera.far = param.far;
2027
2027
  camera.fov = param.param.fov;
@@ -2029,11 +2029,11 @@ class CameraFactory {
2029
2029
  return camera;
2030
2030
  }
2031
2031
  else {
2032
- return new three.PerspectiveCamera(param.param.fov, param.param.aspect, param.near, param.far);
2032
+ return new webgpu.PerspectiveCamera(param.param.fov, param.param.aspect, param.near, param.far);
2033
2033
  }
2034
2034
  }
2035
2035
  if ("left" in param.param && "right" in param.param && "top" in param.param && "bottom" in param.param) {
2036
- if (camera instanceof three.OrthographicCamera) {
2036
+ if (camera instanceof webgpu.OrthographicCamera) {
2037
2037
  camera.near = param.near;
2038
2038
  camera.far = param.far;
2039
2039
  camera.left = param.param.left;
@@ -2043,7 +2043,7 @@ class CameraFactory {
2043
2043
  return camera;
2044
2044
  }
2045
2045
  else {
2046
- return new three.OrthographicCamera(param.param.left, param.param.right, param.param.top, param.param.bottom, param.near, param.far);
2046
+ return new webgpu.OrthographicCamera(param.param.left, param.param.right, param.param.top, param.param.bottom, param.near, param.far);
2047
2047
  }
2048
2048
  }
2049
2049
  return camera;
@@ -2105,7 +2105,7 @@ class ThreeJsApp {
2105
2105
  this._appParam.cameraParam = appParam.cameraParam ? appParam.cameraParam : DefaultCameraParam;
2106
2106
  this._appParam.renderParam = appParam.renderParam ? appParam.renderParam : DefaultRenderParam;
2107
2107
  this._appParam.postProcessParam = appParam.postProcessParam ? appParam.postProcessParam : DefaultPostProcessParam;
2108
- this._clock = new three.Clock();
2108
+ this._clock = new webgpu.Clock();
2109
2109
  this._camera = CameraFactory.createCamera(this._appParam.cameraParam);
2110
2110
  this._world = new this.worldClass(this);
2111
2111
  this._viewport = new this.viewportClass(this, elementId, this._appParam.renderParam, this._appParam.postProcessParam);
@@ -2141,7 +2141,7 @@ class ThreeJsApp {
2141
2141
  this.viewport.markRenderStateDirty();
2142
2142
  }
2143
2143
  onWindowResize(width, height) {
2144
- if (this.camera instanceof three.PerspectiveCamera) {
2144
+ if (this.camera instanceof webgpu.PerspectiveCamera) {
2145
2145
  this.camera.aspect = width / height;
2146
2146
  }
2147
2147
  // if(this.camera instanceof OrthographicCamera)
@@ -2216,7 +2216,7 @@ class Actor extends BaseObject {
2216
2216
  this.constructRootComponent(myThreeObject);
2217
2217
  }
2218
2218
  constructRootComponent(myThreeObject = null) {
2219
- let tObject = myThreeObject ? myThreeObject : new three.Group();
2219
+ let tObject = myThreeObject ? myThreeObject : new webgpu.Group();
2220
2220
  if (tObject.isMesh) {
2221
2221
  let mesh = tObject;
2222
2222
  this._rootComponent = new MeshComponent(mesh);
@@ -2228,7 +2228,7 @@ class Actor extends BaseObject {
2228
2228
  }
2229
2229
  }
2230
2230
  getBoundsCenterPosition(bInWorldSpace = true) {
2231
- let ret = new three.Vector3();
2231
+ let ret = new webgpu.Vector3();
2232
2232
  this.getBounds().getCenter(ret);
2233
2233
  if (!bInWorldSpace) {
2234
2234
  return ret.sub(this.getPosition());
@@ -2238,7 +2238,7 @@ class Actor extends BaseObject {
2238
2238
  }
2239
2239
  }
2240
2240
  getBoundsTopCenterPosition(bInWorldSpace = true) {
2241
- let ret = new three.Vector3();
2241
+ let ret = new webgpu.Vector3();
2242
2242
  let bounds = this.rootComponent.getBounds();
2243
2243
  bounds.getCenter(ret);
2244
2244
  ret.y = bounds.max.y;
@@ -2250,7 +2250,7 @@ class Actor extends BaseObject {
2250
2250
  }
2251
2251
  }
2252
2252
  getBoundsBottomCenterPosition(bInWorldSpace = true) {
2253
- let ret = new three.Vector3();
2253
+ let ret = new webgpu.Vector3();
2254
2254
  let bounds = this.getBounds();
2255
2255
  bounds.getCenter(ret);
2256
2256
  ret.y = bounds.min.y;
@@ -2582,7 +2582,7 @@ class DirectionalLightComponent extends LightComponent {
2582
2582
  this.threeObject.castShadow = value;
2583
2583
  }
2584
2584
  constructor(color = 0xffffff, intensity = 10) {
2585
- let obj = new three.DirectionalLight(color, intensity);
2585
+ let obj = new webgpu.DirectionalLight(color, intensity);
2586
2586
  super(obj);
2587
2587
  this.obj = obj;
2588
2588
  obj.castShadow = true;
@@ -2614,28 +2614,101 @@ class DirectionalLightComponent extends LightComponent {
2614
2614
  class DirectionalLightActor extends Actor {
2615
2615
  constructor(color = 0xffffff, intensity = 1) {
2616
2616
  super();
2617
- this.lightComponent = new DirectionalLightComponent(color, intensity);
2617
+ this.lightComponent = null;
2618
+ this.lightComponent = this.rootComponent;
2619
+ if (this.lightComponent) {
2620
+ this.lightComponent.color = color;
2621
+ this.lightComponent.intensity = intensity;
2622
+ }
2623
+ this.lightComponent.castShadow = true;
2624
+ }
2625
+ constructRootComponent() {
2626
+ this.lightComponent = new DirectionalLightComponent();
2618
2627
  this.rootComponent = this.lightComponent;
2619
2628
  this.lightComponent.castShadow = true;
2629
+ this.rootComponent.parentActor = this;
2620
2630
  }
2621
2631
  }
2622
2632
 
2623
2633
  class BoxComponent extends MeshComponent {
2624
- constructor(width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new three.MeshStandardMaterial()) {
2625
- super(new three.BoxGeometry(width, height, depth, widthSegments, heightSegments, depthSegments), material);
2634
+ constructor(width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new webgpu.MeshStandardMaterial()) {
2635
+ super(new webgpu.BoxGeometry(width, height, depth, widthSegments, heightSegments, depthSegments), material);
2626
2636
  }
2627
2637
  }
2628
2638
 
2629
2639
  class BoxActor extends Actor {
2630
- constructor(width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new three.MeshBasicMaterial()) {
2640
+ constructor(width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new webgpu.MeshBasicMaterial()) {
2631
2641
  super();
2632
2642
  this.addComponent(new BoxComponent(width, height, depth, widthSegments, heightSegments, depthSegments, material));
2633
2643
  }
2634
2644
  }
2635
2645
 
2646
+ const DefaultSkyParam = {
2647
+ turbidity: 10,
2648
+ rayleigh: 2,
2649
+ mieCoefficient: 0.005,
2650
+ mieDirectionalG: 0.8,
2651
+ elevation: 23.44,
2652
+ azimuth: 135,
2653
+ };
2654
+ class SkyComponent extends SceneComponent {
2655
+ get threeObject() {
2656
+ if (!this.obj) {
2657
+ throw Error("three object is invalid");
2658
+ }
2659
+ return this.obj;
2660
+ }
2661
+ set threeObject(newThreeObject) {
2662
+ this.obj = newThreeObject;
2663
+ if (this.obj) {
2664
+ this.obj.userData["LYObject"] = this;
2665
+ }
2666
+ }
2667
+ constructor(skyparam) {
2668
+ let obj = new SkyMesh_js.SkyMesh();
2669
+ super(obj);
2670
+ this.skyParam = DefaultSkyParam;
2671
+ this.sunPosition = new webgpu.Vector3();
2672
+ this.obj = obj;
2673
+ this.name = "SkyComponent";
2674
+ if (skyparam) {
2675
+ this.skyParam = skyparam;
2676
+ }
2677
+ this.updateSky();
2678
+ }
2679
+ updateSky() {
2680
+ var _a, _b;
2681
+ this.threeObject.turbidity.value = this.skyParam.turbidity;
2682
+ this.threeObject.rayleigh.value = this.skyParam.rayleigh;
2683
+ this.threeObject.mieCoefficient.value = this.skyParam.mieCoefficient;
2684
+ this.threeObject.mieDirectionalG.value = this.skyParam.mieDirectionalG;
2685
+ const phi = webgpu.MathUtils.degToRad(90 - this.skyParam.elevation);
2686
+ const theta = webgpu.MathUtils.degToRad(this.skyParam.azimuth);
2687
+ this.sunPosition.setFromSphericalCoords(1, phi, theta);
2688
+ this.threeObject.sunPosition.value.copy(this.sunPosition);
2689
+ (_b = (_a = this.world) === null || _a === void 0 ? void 0 : _a.viewport) === null || _b === void 0 ? void 0 : _b.markRenderStateDirty();
2690
+ }
2691
+ }
2692
+
2693
+ class SkyActor extends Actor {
2694
+ constructor() {
2695
+ super();
2696
+ this._name = "SkyActor";
2697
+ this.skyComponent = null;
2698
+ this.name = "DirectionalLightActor";
2699
+ this.skyComponent = this.rootComponent;
2700
+ this.rootComponent.name = `${this.rootComponent.name}(Root)`;
2701
+ }
2702
+ constructRootComponent() {
2703
+ this.skyComponent = new SkyComponent();
2704
+ this.rootComponent = this.skyComponent;
2705
+ this.rootComponent.parentActor = this;
2706
+ }
2707
+ }
2708
+
2636
2709
  class PlaneComponent extends MeshComponent {
2637
2710
  constructor(width, height, material, widthSegments = 1, heightSegments = 1) {
2638
- super(new three.PlaneGeometry(width, height, widthSegments, heightSegments), material);
2711
+ super(new webgpu.PlaneGeometry(width, height, widthSegments, heightSegments), material);
2639
2712
  }
2640
2713
  }
2641
2714
 
@@ -2643,7 +2716,7 @@ class PlaneActor extends Actor {
2643
2716
  get planeComponent() {
2644
2717
  return this._planeComponent;
2645
2718
  }
2646
- constructor(width, height, material = new three.MeshBasicMaterial(), widthSegments = 1, heightSegments = 1) {
2719
+ constructor(width, height, material = new webgpu.MeshBasicMaterial(), widthSegments = 1, heightSegments = 1) {
2647
2720
  super();
2648
2721
  this._planeComponent = new PlaneComponent(width, height, material, widthSegments, heightSegments);
2649
2722
  this._planeComponent.setRotation(Math.PI * 0.5 * -1, 0, 0);
@@ -2658,44 +2731,9 @@ class PlaneActor extends Actor {
2658
2731
  }
2659
2732
  }
2660
2733
 
2661
- const DefaultBloomParam = {
2662
- threshold: 0,
2663
- strength: 1,
2664
- radius: 0,
2665
- };
2666
-
2667
- const DefaultDenoiseParam = {
2668
- denoiseRadius: 5,
2669
- lumaPhi: 5,
2670
- depthPhi: 5,
2671
- normalPhi: 5
2672
- };
2673
-
2674
- const DefaultDOFParam = {
2675
- focus: 500.0,
2676
- aperture: 5,
2677
- maxblur: 0.01
2678
- };
2679
-
2680
- const DefaultGTAOParam = {
2681
- distanceExponent: 1,
2682
- distanceFallOff: 1,
2683
- radius: 0.25,
2684
- scale: 1,
2685
- thickness: 1,
2686
- denoised: true,
2687
- denoiseParam: DefaultDenoiseParam,
2688
- };
2689
-
2690
- const DefaultSSRParam = {
2691
- maxDistance: 0.5,
2692
- opacity: 1,
2693
- thickness: 0.015,
2694
- };
2695
-
2696
2734
  class SphereComponent extends MeshComponent {
2697
- constructor(radius, material = new three.MeshBasicMaterial(), widthSegments = 32, heightSegments = 16) {
2698
- super(new three.SphereGeometry(radius, widthSegments, heightSegments), material);
2735
+ constructor(radius, material = new webgpu.MeshBasicMaterial(), widthSegments = 32, heightSegments = 16) {
2736
+ super(new webgpu.SphereGeometry(radius, widthSegments, heightSegments), material);
2699
2737
  }
2700
2738
  }
2701
2739
 
@@ -2709,7 +2747,7 @@ class LabelComponent extends SceneComponent {
2709
2747
  this.obj.userData["LYObject"] = this;
2710
2748
  }
2711
2749
  }
2712
- constructor(domElement, center = new three.Vector2(0.5, 1)) {
2750
+ constructor(domElement, center = new webgpu.Vector2(0.5, 1)) {
2713
2751
  let obj = new CSS2DRenderer_js.CSS2DObject(domElement);
2714
2752
  super(obj);
2715
2753
  this.obj = obj;
@@ -2742,6 +2780,41 @@ class LabelComponent extends SceneComponent {
2742
2780
  // labelStyle.style.fontSize = "10px";
2743
2781
  // labelStyle.style.pointerEvents = 'auto';
2744
2782
 
2783
+ const DefaultBloomParam = {
2784
+ threshold: 0,
2785
+ strength: 1,
2786
+ radius: 0,
2787
+ };
2788
+
2789
+ const DefaultDenoiseParam = {
2790
+ denoiseRadius: 5,
2791
+ lumaPhi: 5,
2792
+ depthPhi: 5,
2793
+ normalPhi: 5
2794
+ };
2795
+
2796
+ const DefaultDOFParam = {
2797
+ focus: 500.0,
2798
+ aperture: 5,
2799
+ maxblur: 0.01
2800
+ };
2801
+
2802
+ const DefaultGTAOParam = {
2803
+ distanceExponent: 1,
2804
+ distanceFallOff: 1,
2805
+ radius: 0.25,
2806
+ scale: 1,
2807
+ thickness: 1,
2808
+ denoised: true,
2809
+ denoiseParam: DefaultDenoiseParam,
2810
+ };
2811
+
2812
+ const DefaultSSRParam = {
2813
+ maxDistance: 0.5,
2814
+ opacity: 1,
2815
+ thickness: 0.015,
2816
+ };
2817
+
2745
2818
  class FirstPerson extends Pawn {
2746
2819
  constructor(controller) {
2747
2820
  super(controller);
@@ -2759,7 +2832,7 @@ class TransformGizmo extends Pawn {
2759
2832
  constructor(controller) {
2760
2833
  super(controller);
2761
2834
  this._control = null;
2762
- this.helperObject = new three.Object3D();
2835
+ this.helperObject = new webgpu.Object3D();
2763
2836
  this.targets = [];
2764
2837
  this.primaryTarget = null;
2765
2838
  this.targetMatrixMap = new Map();
@@ -2833,7 +2906,7 @@ class TransformGizmo extends Pawn {
2833
2906
  if (tar !== this.primaryTarget) {
2834
2907
  let t = this.targetMatrixMap.get(tar);
2835
2908
  if (t) {
2836
- let TB2 = new three.Matrix4().multiplyMatrices(TA2, t); // B
2909
+ let TB2 = new webgpu.Matrix4().multiplyMatrices(TA2, t); // B
2837
2910
  tar.onTransforming(TB2);
2838
2911
  }
2839
2912
  }
@@ -2916,6 +2989,7 @@ exports.DefaultOutlineParams = DefaultOutlineParams;
2916
2989
  exports.DefaultPostProcessParam = DefaultPostProcessParam;
2917
2990
  exports.DefaultRenderParam = DefaultRenderParam;
2918
2991
  exports.DefaultSSRParam = DefaultSSRParam;
2992
+ exports.DefaultSkyParam = DefaultSkyParam;
2919
2993
  exports.DefaultToneMappingParams = DefaultToneMappingParams;
2920
2994
  exports.Delegate = Delegate;
2921
2995
  exports.DirectionalLightActor = DirectionalLightActor;
@@ -2929,6 +3003,8 @@ exports.Orbital = Orbital;
2929
3003
  exports.PlaneActor = PlaneActor;
2930
3004
  exports.PlaneComponent = PlaneComponent;
2931
3005
  exports.SceneComponent = SceneComponent;
3006
+ exports.SkyActor = SkyActor;
3007
+ exports.SkyComponent = SkyComponent;
2932
3008
  exports.SphereComponent = SphereComponent;
2933
3009
  exports.ThreeJsApp = ThreeJsApp;
2934
3010
  exports.ThreeObjectLibrary = ThreeObjectLibrary;