lythreeframe 1.2.10 → 1.2.12
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 +113 -131
- package/dist/bundle.esm.js +113 -131
- package/dist/lythreeframe/Object/PawnV2/TransformControl.d.ts +1 -4
- package/package.json +1 -1
package/dist/bundle.cjs.js
CHANGED
|
@@ -154,25 +154,25 @@ class SceneComponent extends Component {
|
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
156
|
get isVisible() {
|
|
157
|
-
if (!this.
|
|
157
|
+
if (!this.obj) {
|
|
158
158
|
return false;
|
|
159
159
|
}
|
|
160
|
-
return this.
|
|
160
|
+
return this.obj.visible;
|
|
161
161
|
}
|
|
162
162
|
setVisible(bVisible) {
|
|
163
|
-
if (!this.
|
|
163
|
+
if (!this.obj) {
|
|
164
164
|
throw Error("threeObject is invalid");
|
|
165
165
|
}
|
|
166
|
-
this.
|
|
166
|
+
this.obj.visible = bVisible;
|
|
167
167
|
if (this.world) {
|
|
168
168
|
this.world.viewport.markRenderStateDirty();
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
setLayers(layer) {
|
|
172
|
-
if (!this.
|
|
172
|
+
if (!this.obj) {
|
|
173
173
|
throw Error("threeObject is invalid");
|
|
174
174
|
}
|
|
175
|
-
this.
|
|
175
|
+
this.obj.layers.set(layer);
|
|
176
176
|
let childComps = this.childrenComponents;
|
|
177
177
|
childComps.forEach((elem) => {
|
|
178
178
|
elem.setLayers(layer);
|
|
@@ -198,11 +198,11 @@ class SceneComponent extends Component {
|
|
|
198
198
|
return ret;
|
|
199
199
|
}
|
|
200
200
|
getBounds() {
|
|
201
|
-
if (!this.
|
|
201
|
+
if (!this.obj) {
|
|
202
202
|
throw Error("threeObject is invalid");
|
|
203
203
|
}
|
|
204
204
|
let ret = new webgpu.Box3();
|
|
205
|
-
ret.setFromObject(this.
|
|
205
|
+
ret.setFromObject(this.obj, false);
|
|
206
206
|
if (ret.isEmpty()) {
|
|
207
207
|
ret.min = ret.max = this.getWorldPosition();
|
|
208
208
|
}
|
|
@@ -210,10 +210,10 @@ class SceneComponent extends Component {
|
|
|
210
210
|
}
|
|
211
211
|
get parentComponent() {
|
|
212
212
|
var _a, _b;
|
|
213
|
-
if (!this.
|
|
213
|
+
if (!this.obj) {
|
|
214
214
|
throw Error("threeObject is invalid");
|
|
215
215
|
}
|
|
216
|
-
let target = (_b = (_a = this.
|
|
216
|
+
let target = (_b = (_a = this.obj) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.userData.LYObject;
|
|
217
217
|
if (!target) {
|
|
218
218
|
return null;
|
|
219
219
|
}
|
|
@@ -226,17 +226,17 @@ class SceneComponent extends Component {
|
|
|
226
226
|
return target;
|
|
227
227
|
}
|
|
228
228
|
get childrenComponents() {
|
|
229
|
-
if (!this.
|
|
229
|
+
if (!this.obj) {
|
|
230
230
|
throw Error("threeObject is invalid");
|
|
231
231
|
}
|
|
232
232
|
let childrens = [];
|
|
233
|
-
for (let i = 0; i < this.
|
|
234
|
-
if (!this.
|
|
235
|
-
// console.warn("One of children component has no parentActor", this.
|
|
233
|
+
for (let i = 0; i < this.obj.children.length; ++i) {
|
|
234
|
+
if (!this.obj.children[i].userData.LYObject) {
|
|
235
|
+
// console.warn("One of children component has no parentActor", this.obj.children[i].userData.LYObject, this.obj.children[i]);
|
|
236
236
|
continue;
|
|
237
237
|
}
|
|
238
|
-
if (this.
|
|
239
|
-
childrens.push(this.
|
|
238
|
+
if (this.obj.children[i].userData.LYObject.parentActor === this.parentActor) {
|
|
239
|
+
childrens.push(this.obj.children[i].userData.LYObject);
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
return childrens;
|
|
@@ -259,33 +259,33 @@ class SceneComponent extends Component {
|
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
261
|
destroyObject() {
|
|
262
|
-
if (!this.
|
|
262
|
+
if (!this.obj) {
|
|
263
263
|
return;
|
|
264
264
|
}
|
|
265
|
-
if (this.
|
|
266
|
-
this.
|
|
265
|
+
if (this.obj.parent) {
|
|
266
|
+
this.obj.parent.remove(this.obj);
|
|
267
267
|
}
|
|
268
268
|
super.destroyObject();
|
|
269
269
|
}
|
|
270
270
|
// Local Transforms
|
|
271
271
|
// // Position
|
|
272
272
|
getPosition() {
|
|
273
|
-
if (!this.
|
|
273
|
+
if (!this.obj) {
|
|
274
274
|
throw Error("threeObject is invalid");
|
|
275
275
|
}
|
|
276
|
-
if (this.
|
|
277
|
-
return this.
|
|
276
|
+
if (this.obj.matrixAutoUpdate) {
|
|
277
|
+
return this.obj.position.clone();
|
|
278
278
|
}
|
|
279
279
|
else {
|
|
280
280
|
const position = new webgpu.Vector3();
|
|
281
281
|
const quaternion = new webgpu.Quaternion();
|
|
282
282
|
const scale = new webgpu.Vector3();
|
|
283
|
-
this.
|
|
283
|
+
this.obj.matrix.decompose(position, quaternion, scale);
|
|
284
284
|
return position;
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
setPosition(...args) {
|
|
288
|
-
if (!this.
|
|
288
|
+
if (!this.obj) {
|
|
289
289
|
throw Error("threeObject is invalid");
|
|
290
290
|
}
|
|
291
291
|
let newPosition = null;
|
|
@@ -301,34 +301,34 @@ class SceneComponent extends Component {
|
|
|
301
301
|
if (!newPosition) {
|
|
302
302
|
return;
|
|
303
303
|
}
|
|
304
|
-
this.
|
|
305
|
-
if (!this.
|
|
306
|
-
this.
|
|
304
|
+
this.obj.position.copy(newPosition);
|
|
305
|
+
if (!this.obj.matrixAutoUpdate) {
|
|
306
|
+
this.obj.matrix.setPosition(newPosition.x, newPosition.y, newPosition.z);
|
|
307
307
|
}
|
|
308
|
-
this.
|
|
309
|
-
this.
|
|
308
|
+
this.obj.updateMatrix();
|
|
309
|
+
this.obj.updateMatrixWorld(true);
|
|
310
310
|
if (this.world) {
|
|
311
311
|
this.world.viewport.markRenderStateDirty();
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
// // Rotation
|
|
315
315
|
getRotation() {
|
|
316
|
-
if (!this.
|
|
316
|
+
if (!this.obj) {
|
|
317
317
|
throw Error("threeObject is invalid");
|
|
318
318
|
}
|
|
319
|
-
if (this.
|
|
320
|
-
return this.
|
|
319
|
+
if (this.obj.matrixAutoUpdate) {
|
|
320
|
+
return this.obj.rotation.clone();
|
|
321
321
|
}
|
|
322
322
|
else {
|
|
323
323
|
const position = new webgpu.Vector3();
|
|
324
324
|
const quaternion = new webgpu.Quaternion();
|
|
325
325
|
const scale = new webgpu.Vector3();
|
|
326
|
-
this.
|
|
326
|
+
this.obj.matrix.decompose(position, quaternion, scale);
|
|
327
327
|
return new webgpu.Euler().setFromQuaternion(quaternion);
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
330
|
setRotation(...args) {
|
|
331
|
-
if (!this.
|
|
331
|
+
if (!this.obj) {
|
|
332
332
|
throw Error("threeObject is invalid");
|
|
333
333
|
}
|
|
334
334
|
let newRotation = null;
|
|
@@ -341,31 +341,31 @@ class SceneComponent extends Component {
|
|
|
341
341
|
if (!newRotation) {
|
|
342
342
|
return;
|
|
343
343
|
}
|
|
344
|
-
this.
|
|
345
|
-
this.
|
|
346
|
-
this.
|
|
344
|
+
this.obj.rotation.copy(newRotation);
|
|
345
|
+
this.obj.updateMatrix();
|
|
346
|
+
this.obj.updateMatrixWorld(true);
|
|
347
347
|
if (this.world) {
|
|
348
348
|
this.world.viewport.markRenderStateDirty();
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
351
|
// // quat
|
|
352
352
|
getQuaternion() {
|
|
353
|
-
if (!this.
|
|
353
|
+
if (!this.obj) {
|
|
354
354
|
throw Error("threeObject is invalid");
|
|
355
355
|
}
|
|
356
|
-
if (this.
|
|
357
|
-
return this.
|
|
356
|
+
if (this.obj.matrixAutoUpdate) {
|
|
357
|
+
return this.obj.quaternion.clone();
|
|
358
358
|
}
|
|
359
359
|
else {
|
|
360
360
|
const position = new webgpu.Vector3();
|
|
361
361
|
const quaternion = new webgpu.Quaternion();
|
|
362
362
|
const scale = new webgpu.Vector3();
|
|
363
|
-
this.
|
|
363
|
+
this.obj.matrix.decompose(position, quaternion, scale);
|
|
364
364
|
return quaternion;
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
367
|
setQuaternion(...args) {
|
|
368
|
-
if (!this.
|
|
368
|
+
if (!this.obj) {
|
|
369
369
|
throw Error("threeObject is invalid");
|
|
370
370
|
}
|
|
371
371
|
let newQuat = null;
|
|
@@ -379,38 +379,38 @@ class SceneComponent extends Component {
|
|
|
379
379
|
console.error("setQuaternion failed,param is invalid", args);
|
|
380
380
|
return;
|
|
381
381
|
}
|
|
382
|
-
this.
|
|
383
|
-
if (!this.
|
|
382
|
+
this.obj.quaternion.copy(newQuat);
|
|
383
|
+
if (!this.obj.matrixAutoUpdate) {
|
|
384
384
|
const position = new webgpu.Vector3();
|
|
385
385
|
const quaternion = new webgpu.Quaternion();
|
|
386
386
|
const scale = new webgpu.Vector3();
|
|
387
|
-
this.
|
|
388
|
-
this.
|
|
387
|
+
this.obj.matrix.decompose(position, quaternion, scale);
|
|
388
|
+
this.obj.matrix.compose(position, newQuat, scale);
|
|
389
389
|
}
|
|
390
390
|
if (this.world) {
|
|
391
391
|
this.world.viewport.markRenderStateDirty();
|
|
392
392
|
}
|
|
393
|
-
this.
|
|
394
|
-
this.
|
|
393
|
+
this.obj.updateMatrix();
|
|
394
|
+
this.obj.updateMatrixWorld(true);
|
|
395
395
|
}
|
|
396
396
|
// // Scale
|
|
397
397
|
getScale() {
|
|
398
|
-
if (!this.
|
|
398
|
+
if (!this.obj) {
|
|
399
399
|
throw Error("threeObject is invalid");
|
|
400
400
|
}
|
|
401
|
-
if (this.
|
|
402
|
-
return this.
|
|
401
|
+
if (this.obj.matrixAutoUpdate) {
|
|
402
|
+
return this.obj.scale.clone();
|
|
403
403
|
}
|
|
404
404
|
else {
|
|
405
405
|
const position = new webgpu.Vector3();
|
|
406
406
|
const quaternion = new webgpu.Quaternion();
|
|
407
407
|
const scale = new webgpu.Vector3();
|
|
408
|
-
this.
|
|
408
|
+
this.obj.matrix.decompose(position, quaternion, scale);
|
|
409
409
|
return scale;
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
412
|
setScale(...args) {
|
|
413
|
-
if (!this.
|
|
413
|
+
if (!this.obj) {
|
|
414
414
|
throw Error("threeObject is invalid");
|
|
415
415
|
}
|
|
416
416
|
let newScale = null;
|
|
@@ -423,123 +423,123 @@ class SceneComponent extends Component {
|
|
|
423
423
|
if (!newScale) {
|
|
424
424
|
return;
|
|
425
425
|
}
|
|
426
|
-
this.
|
|
427
|
-
// if(!this.
|
|
426
|
+
this.obj.scale.copy(newScale);
|
|
427
|
+
// if(!this.obj.matrixAutoUpdate)
|
|
428
428
|
// {
|
|
429
429
|
// const position = new Vector3();
|
|
430
430
|
// const quaternion = new Quaternion()
|
|
431
431
|
// const scale = new Vector3();
|
|
432
|
-
// this.
|
|
433
|
-
// this.
|
|
432
|
+
// this.obj.matrix.decompose(position, quaternion, scale)
|
|
433
|
+
// this.obj.matrix.compose(position, quaternion, new Vector3(param1, param2, param3))
|
|
434
434
|
// }
|
|
435
|
-
this.
|
|
436
|
-
this.
|
|
435
|
+
this.obj.updateMatrix();
|
|
436
|
+
this.obj.updateMatrixWorld(true);
|
|
437
437
|
if (this.world) {
|
|
438
438
|
this.world.viewport.markRenderStateDirty();
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
441
|
// matrix
|
|
442
442
|
getMatrix() {
|
|
443
|
-
if (!this.
|
|
443
|
+
if (!this.obj) {
|
|
444
444
|
throw Error("threeObject is invalid");
|
|
445
445
|
}
|
|
446
|
-
return this.
|
|
446
|
+
return this.obj.matrix;
|
|
447
447
|
}
|
|
448
448
|
setMatrix(matrix) {
|
|
449
449
|
var _a;
|
|
450
|
-
if (!this.
|
|
450
|
+
if (!this.obj) {
|
|
451
451
|
throw Error("threeObject is invalid");
|
|
452
452
|
}
|
|
453
|
-
// this.
|
|
454
|
-
matrix.decompose(this.
|
|
455
|
-
this.
|
|
456
|
-
this.
|
|
453
|
+
// this.obj.matrix.copy(matrix)
|
|
454
|
+
matrix.decompose(this.obj.position, this.obj.quaternion, this.obj.scale);
|
|
455
|
+
this.obj.updateMatrix();
|
|
456
|
+
this.obj.updateMatrixWorld(true);
|
|
457
457
|
(_a = this.world) === null || _a === void 0 ? void 0 : _a.viewport.markRenderStateDirty();
|
|
458
458
|
}
|
|
459
459
|
// World Transform
|
|
460
460
|
// // WorldPosition
|
|
461
461
|
getWorldPosition() {
|
|
462
|
-
if (!this.
|
|
462
|
+
if (!this.obj) {
|
|
463
463
|
throw Error("threeObject is invalid");
|
|
464
464
|
}
|
|
465
465
|
let location = new webgpu.Vector3();
|
|
466
|
-
this.
|
|
466
|
+
this.obj.getWorldPosition(location);
|
|
467
467
|
return location;
|
|
468
468
|
}
|
|
469
469
|
// // rotation(euler)
|
|
470
470
|
getWorldRotation() {
|
|
471
|
-
if (!this.
|
|
471
|
+
if (!this.obj) {
|
|
472
472
|
throw Error("threeObject is invalid");
|
|
473
473
|
}
|
|
474
474
|
let rotation = new webgpu.Quaternion();
|
|
475
|
-
this.
|
|
475
|
+
this.obj.getWorldQuaternion(rotation);
|
|
476
476
|
return new webgpu.Euler().setFromQuaternion(rotation);
|
|
477
477
|
}
|
|
478
478
|
// // rotation(quat)
|
|
479
479
|
getWorldQuaternion() {
|
|
480
|
-
if (!this.
|
|
480
|
+
if (!this.obj) {
|
|
481
481
|
throw Error("threeObject is invalid");
|
|
482
482
|
}
|
|
483
483
|
let rotation = new webgpu.Quaternion();
|
|
484
|
-
this.
|
|
484
|
+
this.obj.getWorldQuaternion(rotation);
|
|
485
485
|
return rotation;
|
|
486
486
|
}
|
|
487
487
|
// // Scale
|
|
488
488
|
getWorldScale() {
|
|
489
|
-
if (!this.
|
|
489
|
+
if (!this.obj) {
|
|
490
490
|
throw Error("threeObject is invalid");
|
|
491
491
|
}
|
|
492
492
|
let scale = new webgpu.Vector3();
|
|
493
|
-
this.
|
|
493
|
+
this.obj.getWorldScale(scale);
|
|
494
494
|
return scale;
|
|
495
495
|
}
|
|
496
496
|
// // Matrix
|
|
497
497
|
getWorldMatrix() {
|
|
498
|
-
if (!this.
|
|
498
|
+
if (!this.obj) {
|
|
499
499
|
throw Error("threeObject is invalid");
|
|
500
500
|
}
|
|
501
|
-
this.
|
|
502
|
-
return this.
|
|
501
|
+
this.obj.updateMatrixWorld(true);
|
|
502
|
+
return this.obj.matrixWorld.clone();
|
|
503
503
|
}
|
|
504
504
|
setWorldMatrix(newMatrix) {
|
|
505
|
-
if (!this.
|
|
505
|
+
if (!this.obj) {
|
|
506
506
|
throw Error("threeObject is invalid");
|
|
507
507
|
}
|
|
508
|
-
if (this.
|
|
509
|
-
this.
|
|
508
|
+
if (this.obj.parent) {
|
|
509
|
+
this.obj.parent.updateMatrixWorld(true);
|
|
510
510
|
// 计算父对象的逆世界矩阵
|
|
511
|
-
const parentInverseWorldMatrix = this.
|
|
511
|
+
const parentInverseWorldMatrix = this.obj.parent.matrixWorld.clone().invert();
|
|
512
512
|
// 计算物体的本地矩阵
|
|
513
513
|
const cLocalMatrix = new webgpu.Matrix4().multiplyMatrices(parentInverseWorldMatrix, newMatrix);
|
|
514
514
|
// 更新物体的本地矩阵
|
|
515
515
|
this.setMatrix(cLocalMatrix);
|
|
516
|
-
// this.
|
|
517
|
-
// this.
|
|
518
|
-
// this.
|
|
516
|
+
// this.obj.matrix.copy(cLocalMatrix);
|
|
517
|
+
// this.obj.matrixAutoUpdate = false;
|
|
518
|
+
// this.obj.matrix.decompose(this.obj.position, this.obj.quaternion, this.obj.scale);
|
|
519
519
|
}
|
|
520
520
|
else {
|
|
521
521
|
this.setMatrix(newMatrix);
|
|
522
522
|
// // 没有父对象时直接设置世界矩阵为本地矩阵
|
|
523
|
-
// this.
|
|
524
|
-
// this.
|
|
523
|
+
// this.obj.matrix.copy(newMatrix);
|
|
524
|
+
// this.obj.matrixAutoUpdate = false;
|
|
525
525
|
}
|
|
526
526
|
// 更新世界矩阵
|
|
527
|
-
this.
|
|
527
|
+
this.obj.updateMatrixWorld(true);
|
|
528
528
|
if (this.world) {
|
|
529
529
|
// 强制场景重新渲染
|
|
530
530
|
this.world.viewport.markRenderStateDirty();
|
|
531
531
|
}
|
|
532
532
|
}
|
|
533
533
|
getWorldForwardDirection() {
|
|
534
|
-
if (!this.
|
|
534
|
+
if (!this.obj) {
|
|
535
535
|
throw Error("threeObject is invalid");
|
|
536
536
|
}
|
|
537
537
|
let ret = new webgpu.Vector3();
|
|
538
|
-
this.
|
|
538
|
+
this.obj.getWorldDirection(ret);
|
|
539
539
|
return ret;
|
|
540
540
|
}
|
|
541
541
|
getWorldUpDirection() {
|
|
542
|
-
if (!this.
|
|
542
|
+
if (!this.obj) {
|
|
543
543
|
throw Error("threeObject is invalid");
|
|
544
544
|
}
|
|
545
545
|
let ret = new webgpu.Vector3(0, 1, 0);
|
|
@@ -547,7 +547,7 @@ class SceneComponent extends Component {
|
|
|
547
547
|
return ret;
|
|
548
548
|
}
|
|
549
549
|
getWorldRightDirection() {
|
|
550
|
-
if (!this.
|
|
550
|
+
if (!this.obj) {
|
|
551
551
|
throw Error("threeObject is invalid");
|
|
552
552
|
}
|
|
553
553
|
let ret = new webgpu.Vector3(1, 0, 0);
|
|
@@ -555,44 +555,44 @@ class SceneComponent extends Component {
|
|
|
555
555
|
return ret;
|
|
556
556
|
}
|
|
557
557
|
worldToLocal(vec) {
|
|
558
|
-
if (!this.
|
|
558
|
+
if (!this.obj) {
|
|
559
559
|
throw Error("threeObject is invalid");
|
|
560
560
|
}
|
|
561
|
-
return this.
|
|
561
|
+
return this.obj.worldToLocal(vec);
|
|
562
562
|
}
|
|
563
563
|
localToWorld(vec) {
|
|
564
|
-
if (!this.
|
|
564
|
+
if (!this.obj) {
|
|
565
565
|
throw Error("threeObject is invalid");
|
|
566
566
|
}
|
|
567
|
-
return this.
|
|
567
|
+
return this.obj.localToWorld(vec);
|
|
568
568
|
}
|
|
569
569
|
// Attachment
|
|
570
570
|
// // to another component
|
|
571
571
|
// this function will not set newComponent's parentActor
|
|
572
572
|
attachComponent(newComponent) {
|
|
573
|
-
if (!this.
|
|
573
|
+
if (!this.obj) {
|
|
574
574
|
throw Error("threeObject is invalid");
|
|
575
575
|
}
|
|
576
576
|
if (!newComponent.threeObject) {
|
|
577
577
|
throw Error("newComponent threeObject is invalid");
|
|
578
578
|
}
|
|
579
|
-
this.
|
|
579
|
+
this.obj.add(newComponent.threeObject);
|
|
580
580
|
if (this.world) {
|
|
581
581
|
newComponent.onAddedToWorld(this.world);
|
|
582
582
|
}
|
|
583
583
|
}
|
|
584
584
|
detachComponent(target) {
|
|
585
|
-
if (!this.
|
|
585
|
+
if (!this.obj) {
|
|
586
586
|
throw Error("threeObject is invalid");
|
|
587
587
|
}
|
|
588
588
|
if (!target.threeObject) {
|
|
589
589
|
throw Error("target threeObject is invalid");
|
|
590
590
|
}
|
|
591
|
-
this.
|
|
591
|
+
this.obj.remove(target.threeObject);
|
|
592
592
|
}
|
|
593
593
|
// newComponent's parentActor will be the same as this
|
|
594
594
|
addChildComponent(newComponent, attachmentRule = exports.AttachmentRules.KeepRelative) {
|
|
595
|
-
if (!this.
|
|
595
|
+
if (!this.obj) {
|
|
596
596
|
throw Error("threeObject is invalid");
|
|
597
597
|
}
|
|
598
598
|
if (!newComponent.threeObject) {
|
|
@@ -601,26 +601,26 @@ class SceneComponent extends Component {
|
|
|
601
601
|
newComponent.parentActor = this.parentActor;
|
|
602
602
|
if (attachmentRule === exports.AttachmentRules.KeepWorld) {
|
|
603
603
|
let worldMatrix = newComponent.getWorldMatrix();
|
|
604
|
-
this.
|
|
604
|
+
this.obj.add(newComponent.threeObject);
|
|
605
605
|
newComponent.setWorldMatrix(worldMatrix);
|
|
606
606
|
}
|
|
607
607
|
else {
|
|
608
|
-
this.
|
|
608
|
+
this.obj.add(newComponent.threeObject);
|
|
609
609
|
}
|
|
610
610
|
if (this.world) {
|
|
611
611
|
newComponent.onAddedToWorld(this.world);
|
|
612
612
|
}
|
|
613
|
-
this.
|
|
614
|
-
this.
|
|
613
|
+
this.obj.updateMatrix();
|
|
614
|
+
this.obj.updateMatrixWorld(true);
|
|
615
615
|
}
|
|
616
616
|
removeChildComponent(targetComponent) {
|
|
617
|
-
if (!this.
|
|
617
|
+
if (!this.obj) {
|
|
618
618
|
throw Error("threeObject is invalid");
|
|
619
619
|
}
|
|
620
620
|
if (!targetComponent.threeObject) {
|
|
621
621
|
throw Error("targetComponent threeObject is invalid");
|
|
622
622
|
}
|
|
623
|
-
this.
|
|
623
|
+
this.obj.remove(targetComponent.threeObject);
|
|
624
624
|
targetComponent.destroy();
|
|
625
625
|
}
|
|
626
626
|
detachFromParentComponent() {
|
|
@@ -635,13 +635,13 @@ class SceneComponent extends Component {
|
|
|
635
635
|
}
|
|
636
636
|
destroyChildren() {
|
|
637
637
|
var _a;
|
|
638
|
-
if (!this.
|
|
638
|
+
if (!this.obj) {
|
|
639
639
|
return;
|
|
640
640
|
}
|
|
641
|
-
for (let i = 0; i < this.
|
|
642
|
-
let obj = (_a = this.
|
|
641
|
+
for (let i = 0; i < this.obj.children.length; ++i) {
|
|
642
|
+
let obj = (_a = this.obj.children[i].userData) === null || _a === void 0 ? void 0 : _a.LYObject;
|
|
643
643
|
if (obj)
|
|
644
|
-
this.
|
|
644
|
+
this.obj.children[i].userData.LYObject.destroy();
|
|
645
645
|
}
|
|
646
646
|
}
|
|
647
647
|
/* horver */
|
|
@@ -3263,17 +3263,8 @@ class TransformGizmo extends Pawn {
|
|
|
3263
3263
|
let q1 = new webgpu.Quaternion();
|
|
3264
3264
|
let s1 = new webgpu.Vector3();
|
|
3265
3265
|
TA2.decompose(p1, q1, s1);
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
this.primaryTarget.onTranslating(p1);
|
|
3269
|
-
}
|
|
3270
|
-
else if (mode === "rotate") {
|
|
3271
|
-
this.primaryTarget.onRotating(q1);
|
|
3272
|
-
}
|
|
3273
|
-
else if (mode === "scale") {
|
|
3274
|
-
this.primaryTarget.onScaling(s1);
|
|
3275
|
-
}
|
|
3276
|
-
// this.primaryTarget.onTransforming(TA2);
|
|
3266
|
+
this.getMode();
|
|
3267
|
+
this.primaryTarget.onTransforming(TA2);
|
|
3277
3268
|
// const TA1Inverse = TA1.clone().invert();
|
|
3278
3269
|
//const transformMatrix = new Matrix4().multiplyMatrices(TA2, TA1Inverse);
|
|
3279
3270
|
this.targets.forEach((tar) => {
|
|
@@ -3285,16 +3276,7 @@ class TransformGizmo extends Pawn {
|
|
|
3285
3276
|
let s2 = new webgpu.Vector3();
|
|
3286
3277
|
let TB2 = new webgpu.Matrix4().multiplyMatrices(TA2, t); // B
|
|
3287
3278
|
TB2.decompose(p2, q2, s2);
|
|
3288
|
-
|
|
3289
|
-
tar.onTranslating(p2);
|
|
3290
|
-
}
|
|
3291
|
-
else if (mode === "rotate") {
|
|
3292
|
-
tar.onRotating(q2);
|
|
3293
|
-
}
|
|
3294
|
-
else if (mode === "scale") {
|
|
3295
|
-
tar.onScaling(s2);
|
|
3296
|
-
}
|
|
3297
|
-
// tar.onTransforming(TB2);
|
|
3279
|
+
tar.onTransforming(TB2);
|
|
3298
3280
|
}
|
|
3299
3281
|
}
|
|
3300
3282
|
});
|
package/dist/bundle.esm.js
CHANGED
|
@@ -152,25 +152,25 @@ class SceneComponent extends Component {
|
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
154
|
get isVisible() {
|
|
155
|
-
if (!this.
|
|
155
|
+
if (!this.obj) {
|
|
156
156
|
return false;
|
|
157
157
|
}
|
|
158
|
-
return this.
|
|
158
|
+
return this.obj.visible;
|
|
159
159
|
}
|
|
160
160
|
setVisible(bVisible) {
|
|
161
|
-
if (!this.
|
|
161
|
+
if (!this.obj) {
|
|
162
162
|
throw Error("threeObject is invalid");
|
|
163
163
|
}
|
|
164
|
-
this.
|
|
164
|
+
this.obj.visible = bVisible;
|
|
165
165
|
if (this.world) {
|
|
166
166
|
this.world.viewport.markRenderStateDirty();
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
setLayers(layer) {
|
|
170
|
-
if (!this.
|
|
170
|
+
if (!this.obj) {
|
|
171
171
|
throw Error("threeObject is invalid");
|
|
172
172
|
}
|
|
173
|
-
this.
|
|
173
|
+
this.obj.layers.set(layer);
|
|
174
174
|
let childComps = this.childrenComponents;
|
|
175
175
|
childComps.forEach((elem) => {
|
|
176
176
|
elem.setLayers(layer);
|
|
@@ -196,11 +196,11 @@ class SceneComponent extends Component {
|
|
|
196
196
|
return ret;
|
|
197
197
|
}
|
|
198
198
|
getBounds() {
|
|
199
|
-
if (!this.
|
|
199
|
+
if (!this.obj) {
|
|
200
200
|
throw Error("threeObject is invalid");
|
|
201
201
|
}
|
|
202
202
|
let ret = new Box3();
|
|
203
|
-
ret.setFromObject(this.
|
|
203
|
+
ret.setFromObject(this.obj, false);
|
|
204
204
|
if (ret.isEmpty()) {
|
|
205
205
|
ret.min = ret.max = this.getWorldPosition();
|
|
206
206
|
}
|
|
@@ -208,10 +208,10 @@ class SceneComponent extends Component {
|
|
|
208
208
|
}
|
|
209
209
|
get parentComponent() {
|
|
210
210
|
var _a, _b;
|
|
211
|
-
if (!this.
|
|
211
|
+
if (!this.obj) {
|
|
212
212
|
throw Error("threeObject is invalid");
|
|
213
213
|
}
|
|
214
|
-
let target = (_b = (_a = this.
|
|
214
|
+
let target = (_b = (_a = this.obj) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.userData.LYObject;
|
|
215
215
|
if (!target) {
|
|
216
216
|
return null;
|
|
217
217
|
}
|
|
@@ -224,17 +224,17 @@ class SceneComponent extends Component {
|
|
|
224
224
|
return target;
|
|
225
225
|
}
|
|
226
226
|
get childrenComponents() {
|
|
227
|
-
if (!this.
|
|
227
|
+
if (!this.obj) {
|
|
228
228
|
throw Error("threeObject is invalid");
|
|
229
229
|
}
|
|
230
230
|
let childrens = [];
|
|
231
|
-
for (let i = 0; i < this.
|
|
232
|
-
if (!this.
|
|
233
|
-
// console.warn("One of children component has no parentActor", this.
|
|
231
|
+
for (let i = 0; i < this.obj.children.length; ++i) {
|
|
232
|
+
if (!this.obj.children[i].userData.LYObject) {
|
|
233
|
+
// console.warn("One of children component has no parentActor", this.obj.children[i].userData.LYObject, this.obj.children[i]);
|
|
234
234
|
continue;
|
|
235
235
|
}
|
|
236
|
-
if (this.
|
|
237
|
-
childrens.push(this.
|
|
236
|
+
if (this.obj.children[i].userData.LYObject.parentActor === this.parentActor) {
|
|
237
|
+
childrens.push(this.obj.children[i].userData.LYObject);
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
240
|
return childrens;
|
|
@@ -257,33 +257,33 @@ class SceneComponent extends Component {
|
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
259
|
destroyObject() {
|
|
260
|
-
if (!this.
|
|
260
|
+
if (!this.obj) {
|
|
261
261
|
return;
|
|
262
262
|
}
|
|
263
|
-
if (this.
|
|
264
|
-
this.
|
|
263
|
+
if (this.obj.parent) {
|
|
264
|
+
this.obj.parent.remove(this.obj);
|
|
265
265
|
}
|
|
266
266
|
super.destroyObject();
|
|
267
267
|
}
|
|
268
268
|
// Local Transforms
|
|
269
269
|
// // Position
|
|
270
270
|
getPosition() {
|
|
271
|
-
if (!this.
|
|
271
|
+
if (!this.obj) {
|
|
272
272
|
throw Error("threeObject is invalid");
|
|
273
273
|
}
|
|
274
|
-
if (this.
|
|
275
|
-
return this.
|
|
274
|
+
if (this.obj.matrixAutoUpdate) {
|
|
275
|
+
return this.obj.position.clone();
|
|
276
276
|
}
|
|
277
277
|
else {
|
|
278
278
|
const position = new Vector3();
|
|
279
279
|
const quaternion = new Quaternion();
|
|
280
280
|
const scale = new Vector3();
|
|
281
|
-
this.
|
|
281
|
+
this.obj.matrix.decompose(position, quaternion, scale);
|
|
282
282
|
return position;
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
285
|
setPosition(...args) {
|
|
286
|
-
if (!this.
|
|
286
|
+
if (!this.obj) {
|
|
287
287
|
throw Error("threeObject is invalid");
|
|
288
288
|
}
|
|
289
289
|
let newPosition = null;
|
|
@@ -299,34 +299,34 @@ class SceneComponent extends Component {
|
|
|
299
299
|
if (!newPosition) {
|
|
300
300
|
return;
|
|
301
301
|
}
|
|
302
|
-
this.
|
|
303
|
-
if (!this.
|
|
304
|
-
this.
|
|
302
|
+
this.obj.position.copy(newPosition);
|
|
303
|
+
if (!this.obj.matrixAutoUpdate) {
|
|
304
|
+
this.obj.matrix.setPosition(newPosition.x, newPosition.y, newPosition.z);
|
|
305
305
|
}
|
|
306
|
-
this.
|
|
307
|
-
this.
|
|
306
|
+
this.obj.updateMatrix();
|
|
307
|
+
this.obj.updateMatrixWorld(true);
|
|
308
308
|
if (this.world) {
|
|
309
309
|
this.world.viewport.markRenderStateDirty();
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
// // Rotation
|
|
313
313
|
getRotation() {
|
|
314
|
-
if (!this.
|
|
314
|
+
if (!this.obj) {
|
|
315
315
|
throw Error("threeObject is invalid");
|
|
316
316
|
}
|
|
317
|
-
if (this.
|
|
318
|
-
return this.
|
|
317
|
+
if (this.obj.matrixAutoUpdate) {
|
|
318
|
+
return this.obj.rotation.clone();
|
|
319
319
|
}
|
|
320
320
|
else {
|
|
321
321
|
const position = new Vector3();
|
|
322
322
|
const quaternion = new Quaternion();
|
|
323
323
|
const scale = new Vector3();
|
|
324
|
-
this.
|
|
324
|
+
this.obj.matrix.decompose(position, quaternion, scale);
|
|
325
325
|
return new Euler().setFromQuaternion(quaternion);
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
328
|
setRotation(...args) {
|
|
329
|
-
if (!this.
|
|
329
|
+
if (!this.obj) {
|
|
330
330
|
throw Error("threeObject is invalid");
|
|
331
331
|
}
|
|
332
332
|
let newRotation = null;
|
|
@@ -339,31 +339,31 @@ class SceneComponent extends Component {
|
|
|
339
339
|
if (!newRotation) {
|
|
340
340
|
return;
|
|
341
341
|
}
|
|
342
|
-
this.
|
|
343
|
-
this.
|
|
344
|
-
this.
|
|
342
|
+
this.obj.rotation.copy(newRotation);
|
|
343
|
+
this.obj.updateMatrix();
|
|
344
|
+
this.obj.updateMatrixWorld(true);
|
|
345
345
|
if (this.world) {
|
|
346
346
|
this.world.viewport.markRenderStateDirty();
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
349
|
// // quat
|
|
350
350
|
getQuaternion() {
|
|
351
|
-
if (!this.
|
|
351
|
+
if (!this.obj) {
|
|
352
352
|
throw Error("threeObject is invalid");
|
|
353
353
|
}
|
|
354
|
-
if (this.
|
|
355
|
-
return this.
|
|
354
|
+
if (this.obj.matrixAutoUpdate) {
|
|
355
|
+
return this.obj.quaternion.clone();
|
|
356
356
|
}
|
|
357
357
|
else {
|
|
358
358
|
const position = new Vector3();
|
|
359
359
|
const quaternion = new Quaternion();
|
|
360
360
|
const scale = new Vector3();
|
|
361
|
-
this.
|
|
361
|
+
this.obj.matrix.decompose(position, quaternion, scale);
|
|
362
362
|
return quaternion;
|
|
363
363
|
}
|
|
364
364
|
}
|
|
365
365
|
setQuaternion(...args) {
|
|
366
|
-
if (!this.
|
|
366
|
+
if (!this.obj) {
|
|
367
367
|
throw Error("threeObject is invalid");
|
|
368
368
|
}
|
|
369
369
|
let newQuat = null;
|
|
@@ -377,38 +377,38 @@ class SceneComponent extends Component {
|
|
|
377
377
|
console.error("setQuaternion failed,param is invalid", args);
|
|
378
378
|
return;
|
|
379
379
|
}
|
|
380
|
-
this.
|
|
381
|
-
if (!this.
|
|
380
|
+
this.obj.quaternion.copy(newQuat);
|
|
381
|
+
if (!this.obj.matrixAutoUpdate) {
|
|
382
382
|
const position = new Vector3();
|
|
383
383
|
const quaternion = new Quaternion();
|
|
384
384
|
const scale = new Vector3();
|
|
385
|
-
this.
|
|
386
|
-
this.
|
|
385
|
+
this.obj.matrix.decompose(position, quaternion, scale);
|
|
386
|
+
this.obj.matrix.compose(position, newQuat, scale);
|
|
387
387
|
}
|
|
388
388
|
if (this.world) {
|
|
389
389
|
this.world.viewport.markRenderStateDirty();
|
|
390
390
|
}
|
|
391
|
-
this.
|
|
392
|
-
this.
|
|
391
|
+
this.obj.updateMatrix();
|
|
392
|
+
this.obj.updateMatrixWorld(true);
|
|
393
393
|
}
|
|
394
394
|
// // Scale
|
|
395
395
|
getScale() {
|
|
396
|
-
if (!this.
|
|
396
|
+
if (!this.obj) {
|
|
397
397
|
throw Error("threeObject is invalid");
|
|
398
398
|
}
|
|
399
|
-
if (this.
|
|
400
|
-
return this.
|
|
399
|
+
if (this.obj.matrixAutoUpdate) {
|
|
400
|
+
return this.obj.scale.clone();
|
|
401
401
|
}
|
|
402
402
|
else {
|
|
403
403
|
const position = new Vector3();
|
|
404
404
|
const quaternion = new Quaternion();
|
|
405
405
|
const scale = new Vector3();
|
|
406
|
-
this.
|
|
406
|
+
this.obj.matrix.decompose(position, quaternion, scale);
|
|
407
407
|
return scale;
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
410
|
setScale(...args) {
|
|
411
|
-
if (!this.
|
|
411
|
+
if (!this.obj) {
|
|
412
412
|
throw Error("threeObject is invalid");
|
|
413
413
|
}
|
|
414
414
|
let newScale = null;
|
|
@@ -421,123 +421,123 @@ class SceneComponent extends Component {
|
|
|
421
421
|
if (!newScale) {
|
|
422
422
|
return;
|
|
423
423
|
}
|
|
424
|
-
this.
|
|
425
|
-
// if(!this.
|
|
424
|
+
this.obj.scale.copy(newScale);
|
|
425
|
+
// if(!this.obj.matrixAutoUpdate)
|
|
426
426
|
// {
|
|
427
427
|
// const position = new Vector3();
|
|
428
428
|
// const quaternion = new Quaternion()
|
|
429
429
|
// const scale = new Vector3();
|
|
430
|
-
// this.
|
|
431
|
-
// this.
|
|
430
|
+
// this.obj.matrix.decompose(position, quaternion, scale)
|
|
431
|
+
// this.obj.matrix.compose(position, quaternion, new Vector3(param1, param2, param3))
|
|
432
432
|
// }
|
|
433
|
-
this.
|
|
434
|
-
this.
|
|
433
|
+
this.obj.updateMatrix();
|
|
434
|
+
this.obj.updateMatrixWorld(true);
|
|
435
435
|
if (this.world) {
|
|
436
436
|
this.world.viewport.markRenderStateDirty();
|
|
437
437
|
}
|
|
438
438
|
}
|
|
439
439
|
// matrix
|
|
440
440
|
getMatrix() {
|
|
441
|
-
if (!this.
|
|
441
|
+
if (!this.obj) {
|
|
442
442
|
throw Error("threeObject is invalid");
|
|
443
443
|
}
|
|
444
|
-
return this.
|
|
444
|
+
return this.obj.matrix;
|
|
445
445
|
}
|
|
446
446
|
setMatrix(matrix) {
|
|
447
447
|
var _a;
|
|
448
|
-
if (!this.
|
|
448
|
+
if (!this.obj) {
|
|
449
449
|
throw Error("threeObject is invalid");
|
|
450
450
|
}
|
|
451
|
-
// this.
|
|
452
|
-
matrix.decompose(this.
|
|
453
|
-
this.
|
|
454
|
-
this.
|
|
451
|
+
// this.obj.matrix.copy(matrix)
|
|
452
|
+
matrix.decompose(this.obj.position, this.obj.quaternion, this.obj.scale);
|
|
453
|
+
this.obj.updateMatrix();
|
|
454
|
+
this.obj.updateMatrixWorld(true);
|
|
455
455
|
(_a = this.world) === null || _a === void 0 ? void 0 : _a.viewport.markRenderStateDirty();
|
|
456
456
|
}
|
|
457
457
|
// World Transform
|
|
458
458
|
// // WorldPosition
|
|
459
459
|
getWorldPosition() {
|
|
460
|
-
if (!this.
|
|
460
|
+
if (!this.obj) {
|
|
461
461
|
throw Error("threeObject is invalid");
|
|
462
462
|
}
|
|
463
463
|
let location = new Vector3();
|
|
464
|
-
this.
|
|
464
|
+
this.obj.getWorldPosition(location);
|
|
465
465
|
return location;
|
|
466
466
|
}
|
|
467
467
|
// // rotation(euler)
|
|
468
468
|
getWorldRotation() {
|
|
469
|
-
if (!this.
|
|
469
|
+
if (!this.obj) {
|
|
470
470
|
throw Error("threeObject is invalid");
|
|
471
471
|
}
|
|
472
472
|
let rotation = new Quaternion();
|
|
473
|
-
this.
|
|
473
|
+
this.obj.getWorldQuaternion(rotation);
|
|
474
474
|
return new Euler().setFromQuaternion(rotation);
|
|
475
475
|
}
|
|
476
476
|
// // rotation(quat)
|
|
477
477
|
getWorldQuaternion() {
|
|
478
|
-
if (!this.
|
|
478
|
+
if (!this.obj) {
|
|
479
479
|
throw Error("threeObject is invalid");
|
|
480
480
|
}
|
|
481
481
|
let rotation = new Quaternion();
|
|
482
|
-
this.
|
|
482
|
+
this.obj.getWorldQuaternion(rotation);
|
|
483
483
|
return rotation;
|
|
484
484
|
}
|
|
485
485
|
// // Scale
|
|
486
486
|
getWorldScale() {
|
|
487
|
-
if (!this.
|
|
487
|
+
if (!this.obj) {
|
|
488
488
|
throw Error("threeObject is invalid");
|
|
489
489
|
}
|
|
490
490
|
let scale = new Vector3();
|
|
491
|
-
this.
|
|
491
|
+
this.obj.getWorldScale(scale);
|
|
492
492
|
return scale;
|
|
493
493
|
}
|
|
494
494
|
// // Matrix
|
|
495
495
|
getWorldMatrix() {
|
|
496
|
-
if (!this.
|
|
496
|
+
if (!this.obj) {
|
|
497
497
|
throw Error("threeObject is invalid");
|
|
498
498
|
}
|
|
499
|
-
this.
|
|
500
|
-
return this.
|
|
499
|
+
this.obj.updateMatrixWorld(true);
|
|
500
|
+
return this.obj.matrixWorld.clone();
|
|
501
501
|
}
|
|
502
502
|
setWorldMatrix(newMatrix) {
|
|
503
|
-
if (!this.
|
|
503
|
+
if (!this.obj) {
|
|
504
504
|
throw Error("threeObject is invalid");
|
|
505
505
|
}
|
|
506
|
-
if (this.
|
|
507
|
-
this.
|
|
506
|
+
if (this.obj.parent) {
|
|
507
|
+
this.obj.parent.updateMatrixWorld(true);
|
|
508
508
|
// 计算父对象的逆世界矩阵
|
|
509
|
-
const parentInverseWorldMatrix = this.
|
|
509
|
+
const parentInverseWorldMatrix = this.obj.parent.matrixWorld.clone().invert();
|
|
510
510
|
// 计算物体的本地矩阵
|
|
511
511
|
const cLocalMatrix = new Matrix4().multiplyMatrices(parentInverseWorldMatrix, newMatrix);
|
|
512
512
|
// 更新物体的本地矩阵
|
|
513
513
|
this.setMatrix(cLocalMatrix);
|
|
514
|
-
// this.
|
|
515
|
-
// this.
|
|
516
|
-
// this.
|
|
514
|
+
// this.obj.matrix.copy(cLocalMatrix);
|
|
515
|
+
// this.obj.matrixAutoUpdate = false;
|
|
516
|
+
// this.obj.matrix.decompose(this.obj.position, this.obj.quaternion, this.obj.scale);
|
|
517
517
|
}
|
|
518
518
|
else {
|
|
519
519
|
this.setMatrix(newMatrix);
|
|
520
520
|
// // 没有父对象时直接设置世界矩阵为本地矩阵
|
|
521
|
-
// this.
|
|
522
|
-
// this.
|
|
521
|
+
// this.obj.matrix.copy(newMatrix);
|
|
522
|
+
// this.obj.matrixAutoUpdate = false;
|
|
523
523
|
}
|
|
524
524
|
// 更新世界矩阵
|
|
525
|
-
this.
|
|
525
|
+
this.obj.updateMatrixWorld(true);
|
|
526
526
|
if (this.world) {
|
|
527
527
|
// 强制场景重新渲染
|
|
528
528
|
this.world.viewport.markRenderStateDirty();
|
|
529
529
|
}
|
|
530
530
|
}
|
|
531
531
|
getWorldForwardDirection() {
|
|
532
|
-
if (!this.
|
|
532
|
+
if (!this.obj) {
|
|
533
533
|
throw Error("threeObject is invalid");
|
|
534
534
|
}
|
|
535
535
|
let ret = new Vector3();
|
|
536
|
-
this.
|
|
536
|
+
this.obj.getWorldDirection(ret);
|
|
537
537
|
return ret;
|
|
538
538
|
}
|
|
539
539
|
getWorldUpDirection() {
|
|
540
|
-
if (!this.
|
|
540
|
+
if (!this.obj) {
|
|
541
541
|
throw Error("threeObject is invalid");
|
|
542
542
|
}
|
|
543
543
|
let ret = new Vector3(0, 1, 0);
|
|
@@ -545,7 +545,7 @@ class SceneComponent extends Component {
|
|
|
545
545
|
return ret;
|
|
546
546
|
}
|
|
547
547
|
getWorldRightDirection() {
|
|
548
|
-
if (!this.
|
|
548
|
+
if (!this.obj) {
|
|
549
549
|
throw Error("threeObject is invalid");
|
|
550
550
|
}
|
|
551
551
|
let ret = new Vector3(1, 0, 0);
|
|
@@ -553,44 +553,44 @@ class SceneComponent extends Component {
|
|
|
553
553
|
return ret;
|
|
554
554
|
}
|
|
555
555
|
worldToLocal(vec) {
|
|
556
|
-
if (!this.
|
|
556
|
+
if (!this.obj) {
|
|
557
557
|
throw Error("threeObject is invalid");
|
|
558
558
|
}
|
|
559
|
-
return this.
|
|
559
|
+
return this.obj.worldToLocal(vec);
|
|
560
560
|
}
|
|
561
561
|
localToWorld(vec) {
|
|
562
|
-
if (!this.
|
|
562
|
+
if (!this.obj) {
|
|
563
563
|
throw Error("threeObject is invalid");
|
|
564
564
|
}
|
|
565
|
-
return this.
|
|
565
|
+
return this.obj.localToWorld(vec);
|
|
566
566
|
}
|
|
567
567
|
// Attachment
|
|
568
568
|
// // to another component
|
|
569
569
|
// this function will not set newComponent's parentActor
|
|
570
570
|
attachComponent(newComponent) {
|
|
571
|
-
if (!this.
|
|
571
|
+
if (!this.obj) {
|
|
572
572
|
throw Error("threeObject is invalid");
|
|
573
573
|
}
|
|
574
574
|
if (!newComponent.threeObject) {
|
|
575
575
|
throw Error("newComponent threeObject is invalid");
|
|
576
576
|
}
|
|
577
|
-
this.
|
|
577
|
+
this.obj.add(newComponent.threeObject);
|
|
578
578
|
if (this.world) {
|
|
579
579
|
newComponent.onAddedToWorld(this.world);
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
582
|
detachComponent(target) {
|
|
583
|
-
if (!this.
|
|
583
|
+
if (!this.obj) {
|
|
584
584
|
throw Error("threeObject is invalid");
|
|
585
585
|
}
|
|
586
586
|
if (!target.threeObject) {
|
|
587
587
|
throw Error("target threeObject is invalid");
|
|
588
588
|
}
|
|
589
|
-
this.
|
|
589
|
+
this.obj.remove(target.threeObject);
|
|
590
590
|
}
|
|
591
591
|
// newComponent's parentActor will be the same as this
|
|
592
592
|
addChildComponent(newComponent, attachmentRule = AttachmentRules.KeepRelative) {
|
|
593
|
-
if (!this.
|
|
593
|
+
if (!this.obj) {
|
|
594
594
|
throw Error("threeObject is invalid");
|
|
595
595
|
}
|
|
596
596
|
if (!newComponent.threeObject) {
|
|
@@ -599,26 +599,26 @@ class SceneComponent extends Component {
|
|
|
599
599
|
newComponent.parentActor = this.parentActor;
|
|
600
600
|
if (attachmentRule === AttachmentRules.KeepWorld) {
|
|
601
601
|
let worldMatrix = newComponent.getWorldMatrix();
|
|
602
|
-
this.
|
|
602
|
+
this.obj.add(newComponent.threeObject);
|
|
603
603
|
newComponent.setWorldMatrix(worldMatrix);
|
|
604
604
|
}
|
|
605
605
|
else {
|
|
606
|
-
this.
|
|
606
|
+
this.obj.add(newComponent.threeObject);
|
|
607
607
|
}
|
|
608
608
|
if (this.world) {
|
|
609
609
|
newComponent.onAddedToWorld(this.world);
|
|
610
610
|
}
|
|
611
|
-
this.
|
|
612
|
-
this.
|
|
611
|
+
this.obj.updateMatrix();
|
|
612
|
+
this.obj.updateMatrixWorld(true);
|
|
613
613
|
}
|
|
614
614
|
removeChildComponent(targetComponent) {
|
|
615
|
-
if (!this.
|
|
615
|
+
if (!this.obj) {
|
|
616
616
|
throw Error("threeObject is invalid");
|
|
617
617
|
}
|
|
618
618
|
if (!targetComponent.threeObject) {
|
|
619
619
|
throw Error("targetComponent threeObject is invalid");
|
|
620
620
|
}
|
|
621
|
-
this.
|
|
621
|
+
this.obj.remove(targetComponent.threeObject);
|
|
622
622
|
targetComponent.destroy();
|
|
623
623
|
}
|
|
624
624
|
detachFromParentComponent() {
|
|
@@ -633,13 +633,13 @@ class SceneComponent extends Component {
|
|
|
633
633
|
}
|
|
634
634
|
destroyChildren() {
|
|
635
635
|
var _a;
|
|
636
|
-
if (!this.
|
|
636
|
+
if (!this.obj) {
|
|
637
637
|
return;
|
|
638
638
|
}
|
|
639
|
-
for (let i = 0; i < this.
|
|
640
|
-
let obj = (_a = this.
|
|
639
|
+
for (let i = 0; i < this.obj.children.length; ++i) {
|
|
640
|
+
let obj = (_a = this.obj.children[i].userData) === null || _a === void 0 ? void 0 : _a.LYObject;
|
|
641
641
|
if (obj)
|
|
642
|
-
this.
|
|
642
|
+
this.obj.children[i].userData.LYObject.destroy();
|
|
643
643
|
}
|
|
644
644
|
}
|
|
645
645
|
/* horver */
|
|
@@ -3261,17 +3261,8 @@ class TransformGizmo extends Pawn {
|
|
|
3261
3261
|
let q1 = new Quaternion();
|
|
3262
3262
|
let s1 = new Vector3();
|
|
3263
3263
|
TA2.decompose(p1, q1, s1);
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
this.primaryTarget.onTranslating(p1);
|
|
3267
|
-
}
|
|
3268
|
-
else if (mode === "rotate") {
|
|
3269
|
-
this.primaryTarget.onRotating(q1);
|
|
3270
|
-
}
|
|
3271
|
-
else if (mode === "scale") {
|
|
3272
|
-
this.primaryTarget.onScaling(s1);
|
|
3273
|
-
}
|
|
3274
|
-
// this.primaryTarget.onTransforming(TA2);
|
|
3264
|
+
this.getMode();
|
|
3265
|
+
this.primaryTarget.onTransforming(TA2);
|
|
3275
3266
|
// const TA1Inverse = TA1.clone().invert();
|
|
3276
3267
|
//const transformMatrix = new Matrix4().multiplyMatrices(TA2, TA1Inverse);
|
|
3277
3268
|
this.targets.forEach((tar) => {
|
|
@@ -3283,16 +3274,7 @@ class TransformGizmo extends Pawn {
|
|
|
3283
3274
|
let s2 = new Vector3();
|
|
3284
3275
|
let TB2 = new Matrix4().multiplyMatrices(TA2, t); // B
|
|
3285
3276
|
TB2.decompose(p2, q2, s2);
|
|
3286
|
-
|
|
3287
|
-
tar.onTranslating(p2);
|
|
3288
|
-
}
|
|
3289
|
-
else if (mode === "rotate") {
|
|
3290
|
-
tar.onRotating(q2);
|
|
3291
|
-
}
|
|
3292
|
-
else if (mode === "scale") {
|
|
3293
|
-
tar.onScaling(s2);
|
|
3294
|
-
}
|
|
3295
|
-
// tar.onTransforming(TB2);
|
|
3277
|
+
tar.onTransforming(TB2);
|
|
3296
3278
|
}
|
|
3297
3279
|
}
|
|
3298
3280
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Pawn } from "./Pawn";
|
|
2
|
-
import { Matrix4
|
|
2
|
+
import { Matrix4 } from "three/webgpu";
|
|
3
3
|
import { TransformControls } from "three/examples/jsm/controls/TransformControls.js";
|
|
4
4
|
import { Controller } from "../../Frame/Controller";
|
|
5
5
|
export interface TransformType {
|
|
@@ -10,9 +10,6 @@ export interface TransformType {
|
|
|
10
10
|
export interface ITransforming {
|
|
11
11
|
isTransformAllowed(): boolean;
|
|
12
12
|
onTransforming(worldMatrix: Matrix4): void;
|
|
13
|
-
onTranslating(worldPos: Vector3): void;
|
|
14
|
-
onRotating(worldQuat: Quaternion): void;
|
|
15
|
-
onScaling(worldScale: Vector3): void;
|
|
16
13
|
getMatrixInWorld(): Matrix4;
|
|
17
14
|
getAllowedTransformType(): TransformType;
|
|
18
15
|
}
|