@archvisioninc/canvas 2.4.5 → 2.4.7
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.
|
@@ -332,11 +332,12 @@ const initMetadataKeyDefaults = () => {
|
|
|
332
332
|
};
|
|
333
333
|
const checkForRootNode = () => {
|
|
334
334
|
let rootNode = scene.getNodeById('__root__');
|
|
335
|
-
let node0 =
|
|
335
|
+
let node0 = rootNode?.getChildren()?.find?.((child, index) => child.name === node0Name && index === 0);
|
|
336
336
|
const isTransformNode = item => item?.getClassName() === 'TransformNode';
|
|
337
337
|
const userMeshes = getUserMeshes();
|
|
338
338
|
const userNodes = getUserNodes();
|
|
339
339
|
const topLevelUserNodes = userNodes.filter(node => node.parent === null);
|
|
340
|
+
const otherNode0Nodes = userNodes?.filter(node => node.name === node0Name && node.parent !== rootNode);
|
|
340
341
|
if (!rootNode) {
|
|
341
342
|
rootNode = new BABYLON.Mesh('__root__', scene);
|
|
342
343
|
rootNode.isPickable = false;
|
|
@@ -345,7 +346,7 @@ const checkForRootNode = () => {
|
|
|
345
346
|
rootNode.isPointerBlocker = true;
|
|
346
347
|
rootNode.isHitTestVisible = false;
|
|
347
348
|
}
|
|
348
|
-
if (!
|
|
349
|
+
if (!node0 || !isTransformNode(node0)) {
|
|
349
350
|
node0 = new BABYLON.TransformNode(node0Name, scene);
|
|
350
351
|
node0.isPickable = false;
|
|
351
352
|
node0.isVisible = false;
|
|
@@ -355,6 +356,11 @@ const checkForRootNode = () => {
|
|
|
355
356
|
node0.parent = rootNode;
|
|
356
357
|
}
|
|
357
358
|
|
|
359
|
+
// NOTE: This renames all other node0's to avoid conflict with the main node0 for transformations etc.
|
|
360
|
+
if (!_.isEmpty(otherNode0Nodes)) {
|
|
361
|
+
otherNode0Nodes?.forEach((node, index) => node.name = `node0_(${index})`);
|
|
362
|
+
}
|
|
363
|
+
|
|
358
364
|
// NOTE: This handles correcting any third-party files that have __root__ and children
|
|
359
365
|
// but not node0, and makes sure everything is a child of the newly created node0.
|
|
360
366
|
rootNode.getChildren().forEach(child => {
|
|
@@ -362,16 +368,17 @@ const checkForRootNode = () => {
|
|
|
362
368
|
const isNode0 = child.name === node0Name && transformNode;
|
|
363
369
|
const parentedToNode0 = child.parent.name === node0Name && transformNode;
|
|
364
370
|
const hasNode0AsChild = child.getChildren().find(node => node.name === node0Name);
|
|
365
|
-
if (!isNode0 && !parentedToNode0 && !hasNode0AsChild)
|
|
371
|
+
if (!isNode0 && !parentedToNode0 && !hasNode0AsChild) {
|
|
372
|
+
child.setParent(node0);
|
|
373
|
+
}
|
|
366
374
|
});
|
|
367
375
|
|
|
368
376
|
// NOTE: This handles correcting any parentless user meshes from a third-party file and makes
|
|
369
|
-
// sure they are parented to node0.
|
|
377
|
+
// sure they are named with the prefix "mesh" and parented to node0.
|
|
370
378
|
userMeshes.forEach(mesh => {
|
|
371
379
|
if (mesh.name === node0Name && !isTransformNode(mesh)) mesh.name = 'mesh0';
|
|
372
380
|
if (mesh.parent === null) mesh.setParent(node0);
|
|
373
381
|
});
|
|
374
|
-
if (node0.parent !== rootNode) node0.setParent(rootNode);
|
|
375
382
|
|
|
376
383
|
// NOTE: This handles correcting any parentless user nodes from a third-party file and makes
|
|
377
384
|
// sure they are parented to node0.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
1
2
|
import * as BABYLON from 'babylonjs';
|
|
2
3
|
|
|
3
|
-
// GLTFFileLoader needs to be declared for the GLTF loader to work -- even if unused
|
|
4
|
-
// eslint-disable-next-line
|
|
4
|
+
// GLTFFileLoader needs to be declared for the GLTF loader to work -- even if unused.
|
|
5
|
+
// eslint-disable-next-line no-unused-vars
|
|
5
6
|
import { GLTFFileLoader } from 'babylonjs-loaders';
|
|
6
7
|
import { reactProps as props } from '../Canvas';
|
|
7
8
|
import { DRAG_DROP_FORMATS } from '../enums';
|
|
@@ -219,7 +220,21 @@ export const loadFromDragDrop = () => {
|
|
|
219
220
|
const onProgress = null;
|
|
220
221
|
const additionalRenderLoopLogic = null;
|
|
221
222
|
const textureLoading = null;
|
|
222
|
-
const startingProcessingFiles = () =>
|
|
223
|
+
const startingProcessingFiles = () => {
|
|
224
|
+
const hasGuid = !_.isEmpty(props.guidURL);
|
|
225
|
+
if (hasGuid) {
|
|
226
|
+
const message = "This model has published data that can't be updated from a drag and drop operation. Use Create from gLTF to start a new file.";
|
|
227
|
+
const config = {
|
|
228
|
+
type: MESSAGE_TYPES.warning
|
|
229
|
+
};
|
|
230
|
+
props.addNotification?.([{
|
|
231
|
+
message,
|
|
232
|
+
config
|
|
233
|
+
}], clearExisting);
|
|
234
|
+
throw new Error(message);
|
|
235
|
+
}
|
|
236
|
+
checkSupportedFileTypes();
|
|
237
|
+
};
|
|
223
238
|
const onReload = null;
|
|
224
239
|
const onError = (file, scene, error) => {
|
|
225
240
|
const missingBin = error.includes('.bin');
|
package/package.json
CHANGED
|
@@ -371,11 +371,12 @@ const initMetadataKeyDefaults = () => {
|
|
|
371
371
|
|
|
372
372
|
const checkForRootNode = () => {
|
|
373
373
|
let rootNode = scene.getNodeById('__root__');
|
|
374
|
-
let node0 =
|
|
374
|
+
let node0 = rootNode?.getChildren()?.find?.((child, index) => child.name === node0Name && index === 0);
|
|
375
375
|
const isTransformNode = item => item?.getClassName() === 'TransformNode';
|
|
376
376
|
const userMeshes = getUserMeshes();
|
|
377
377
|
const userNodes = getUserNodes();
|
|
378
378
|
const topLevelUserNodes = userNodes.filter(node => node.parent === null);
|
|
379
|
+
const otherNode0Nodes = userNodes?.filter(node => node.name === node0Name && node.parent !== rootNode);
|
|
379
380
|
|
|
380
381
|
if (!rootNode) {
|
|
381
382
|
rootNode = new BABYLON.Mesh('__root__', scene);
|
|
@@ -386,7 +387,7 @@ const checkForRootNode = () => {
|
|
|
386
387
|
rootNode.isHitTestVisible = false;
|
|
387
388
|
}
|
|
388
389
|
|
|
389
|
-
if (!
|
|
390
|
+
if (!node0 || !isTransformNode(node0)) {
|
|
390
391
|
node0 = new BABYLON.TransformNode(node0Name, scene);
|
|
391
392
|
node0.isPickable = false;
|
|
392
393
|
node0.isVisible = false;
|
|
@@ -396,6 +397,11 @@ const checkForRootNode = () => {
|
|
|
396
397
|
node0.parent = rootNode;
|
|
397
398
|
}
|
|
398
399
|
|
|
400
|
+
// NOTE: This renames all other node0's to avoid conflict with the main node0 for transformations etc.
|
|
401
|
+
if (!_.isEmpty(otherNode0Nodes)) {
|
|
402
|
+
otherNode0Nodes?.forEach((node, index) => node.name = `node0_(${index})`);
|
|
403
|
+
}
|
|
404
|
+
|
|
399
405
|
// NOTE: This handles correcting any third-party files that have __root__ and children
|
|
400
406
|
// but not node0, and makes sure everything is a child of the newly created node0.
|
|
401
407
|
rootNode.getChildren().forEach(child => {
|
|
@@ -404,18 +410,18 @@ const checkForRootNode = () => {
|
|
|
404
410
|
const parentedToNode0 = child.parent.name === node0Name && transformNode;
|
|
405
411
|
const hasNode0AsChild = child.getChildren().find(node => node.name === node0Name);
|
|
406
412
|
|
|
407
|
-
if (!isNode0 && !parentedToNode0 && !hasNode0AsChild)
|
|
413
|
+
if (!isNode0 && !parentedToNode0 && !hasNode0AsChild) {
|
|
414
|
+
child.setParent(node0);
|
|
415
|
+
}
|
|
408
416
|
});
|
|
409
417
|
|
|
410
418
|
// NOTE: This handles correcting any parentless user meshes from a third-party file and makes
|
|
411
|
-
// sure they are parented to node0.
|
|
419
|
+
// sure they are named with the prefix "mesh" and parented to node0.
|
|
412
420
|
userMeshes.forEach(mesh => {
|
|
413
421
|
if (mesh.name === node0Name && !isTransformNode(mesh)) mesh.name = 'mesh0';
|
|
414
422
|
if (mesh.parent === null) mesh.setParent(node0);
|
|
415
423
|
});
|
|
416
424
|
|
|
417
|
-
if (node0.parent !== rootNode) node0.setParent(rootNode);
|
|
418
|
-
|
|
419
425
|
// NOTE: This handles correcting any parentless user nodes from a third-party file and makes
|
|
420
426
|
// sure they are parented to node0.
|
|
421
427
|
topLevelUserNodes?.forEach(node => node.setParent(node0));
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
1
2
|
import * as BABYLON from 'babylonjs';
|
|
2
3
|
|
|
3
|
-
// GLTFFileLoader needs to be declared for the GLTF loader to work -- even if unused
|
|
4
|
-
// eslint-disable-next-line
|
|
4
|
+
// GLTFFileLoader needs to be declared for the GLTF loader to work -- even if unused.
|
|
5
|
+
// eslint-disable-next-line no-unused-vars
|
|
5
6
|
import { GLTFFileLoader } from 'babylonjs-loaders';
|
|
6
7
|
|
|
7
8
|
import { reactProps as props } from '../Canvas';
|
|
@@ -235,15 +236,29 @@ let filesInput;
|
|
|
235
236
|
|
|
236
237
|
export const loadFromDragDrop = () => {
|
|
237
238
|
const handleCloseLoading = () => props.clearNotifications?.();
|
|
239
|
+
|
|
238
240
|
const sceneLoaded = (file, newScene) => {
|
|
239
241
|
const fileName = file.name.split('.').shift();
|
|
240
242
|
initSceneFromFile(newScene, fileName);
|
|
241
243
|
modelToOrigin();
|
|
242
244
|
};
|
|
245
|
+
|
|
243
246
|
const onProgress = null;
|
|
244
247
|
const additionalRenderLoopLogic = null;
|
|
245
248
|
const textureLoading = null;
|
|
246
|
-
const startingProcessingFiles = () =>
|
|
249
|
+
const startingProcessingFiles = () => {
|
|
250
|
+
const hasGuid = !_.isEmpty(props.guidURL);
|
|
251
|
+
|
|
252
|
+
if (hasGuid) {
|
|
253
|
+
const message = "This model has published data that can't be updated from a drag and drop operation. Use Create from gLTF to start a new file.";
|
|
254
|
+
const config = { type: MESSAGE_TYPES.warning };
|
|
255
|
+
|
|
256
|
+
props.addNotification?.([ { message, config } ], clearExisting);
|
|
257
|
+
throw new Error(message);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
checkSupportedFileTypes();
|
|
261
|
+
};
|
|
247
262
|
const onReload = null;
|
|
248
263
|
|
|
249
264
|
const onError = (file, scene, error) => {
|