@archvisioninc/canvas 2.4.9 → 2.5.1
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as BABYLON from 'babylonjs';
|
|
2
2
|
import { newVector } from './utilityHelpers';
|
|
3
|
-
import { scene, engine, canvas, selectedMeshes, getParamOfSelectedMeshes, getUserMeshes, defaultCameraPosition } from '../helpers';
|
|
3
|
+
import { scene, engine, canvas, selectedMeshes, getParamOfSelectedMeshes, getUserMeshes, defaultCameraPosition, getBoundingMeshData } from '../helpers';
|
|
4
4
|
import { CAMERAS, MESH_PARAMS } from '../constants';
|
|
5
5
|
import { focusCamera, toggleTurntable } from '../actions';
|
|
6
6
|
import { orthoOptions, ratios } from '../enums';
|
|
@@ -35,14 +35,20 @@ export const prepareCamera = () => {
|
|
|
35
35
|
};
|
|
36
36
|
export const prepareMaterialCamera = () => {
|
|
37
37
|
const camera = scene.activeCamera;
|
|
38
|
-
const
|
|
38
|
+
const base = scene.getMeshById('node2');
|
|
39
|
+
const sphere = scene.getMeshById('node4');
|
|
39
40
|
camera.position = defaultCameraPosition();
|
|
40
|
-
if (
|
|
41
|
-
const
|
|
41
|
+
if (base && sphere) {
|
|
42
|
+
const primarySurfaces = [sphere, base];
|
|
43
|
+
const meshCenter = getBoundingMeshData(primarySurfaces).center;
|
|
42
44
|
camera.setTarget(meshCenter);
|
|
43
45
|
camera.alpha = 1.57;
|
|
44
|
-
camera.beta = 1.
|
|
45
|
-
camera.
|
|
46
|
+
camera.beta = 1.35;
|
|
47
|
+
camera.lowerRadiusLimit = 0.3239;
|
|
48
|
+
camera.upperRadiusLimit = 5000;
|
|
49
|
+
camera.minZ = 0.1;
|
|
50
|
+
camera.maxZ = 10000;
|
|
51
|
+
camera.radius = 0.785;
|
|
46
52
|
}
|
|
47
53
|
};
|
|
48
54
|
export const toggleCameraMode = (orthoCamera, requestedMode) => {
|
|
@@ -63,6 +63,8 @@ const tweakSceneForShaderball = () => {
|
|
|
63
63
|
if (yAxis) yAxis.isVisible = false;
|
|
64
64
|
if (zAxis) zAxis.isVisible = false;
|
|
65
65
|
if (ground) ground.isVisible = false;
|
|
66
|
+
const mainMaterial = scene.getMaterialById('material');
|
|
67
|
+
newMetaDataEntry('selectedMaterial', mainMaterial?.id);
|
|
66
68
|
prepareMaterialCamera();
|
|
67
69
|
props.clearNotifications?.();
|
|
68
70
|
};
|
|
@@ -100,11 +102,9 @@ const initCamera = () => {
|
|
|
100
102
|
z: 0
|
|
101
103
|
};
|
|
102
104
|
newCamera('defaultCamera', cameraLocation, CAMERAS.ArcRotateCamera, cameraMeta);
|
|
103
|
-
if (props.materialMode) {
|
|
104
|
-
|
|
105
|
-
return;
|
|
105
|
+
if (!props.materialMode) {
|
|
106
|
+
prepareCamera();
|
|
106
107
|
}
|
|
107
|
-
prepareCamera();
|
|
108
108
|
};
|
|
109
109
|
const initGUI = () => {
|
|
110
110
|
const aspectRatio = props.ratio?.value || ratios.broadcast.value;
|
package/package.json
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { MESSAGE_TYPES } from 'package/constants';
|
|
2
2
|
import { progressConfig } from 'package/helpers';
|
|
3
|
+
import _ from 'lodash';
|
|
3
4
|
|
|
4
5
|
const clearExisting = true;
|
|
5
6
|
|
|
6
7
|
export const fetchDownloadURL = async args => {
|
|
7
|
-
const { addNotification, clearNotifications, setPreviewURL } = args;
|
|
8
|
+
const { addNotification, rpcGuid, clearNotifications, setPreviewURL } = args;
|
|
8
9
|
|
|
9
10
|
try {
|
|
10
|
-
const rpcGuid = window.location.pathname.split('/')[1];
|
|
11
11
|
const format = 'GLB';
|
|
12
12
|
const message = 'Getting file from GUID...';
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
if (rpcGuid) {
|
|
14
|
+
if (!_.isEmpty(rpcGuid)) {
|
|
16
15
|
const servicesURL = `https://api.archvision.services/rpc/v1/integration/${rpcGuid}/download/${format}`;
|
|
17
16
|
// eslint-disable-next-line
|
|
18
|
-
const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.
|
|
17
|
+
const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2FyY2h2aXNpb24uY29tIiwic3ViIjozOTUxNTcsInRva2VuX3R5cGUiOiJiZWFyZXIiLCJzY29wZSI6ImJhc2ljIiwiYXVkIjoiNDVFUnF3SEV5SWRqbXhkaUU4MUxMbDlFYTN2SzZZQ3dLNWE2R2xEMyIsImlhdCI6MTY5NTA0MTc0MCwiZXhwIjoxNzAwMjI1NzQwfQ.xTj9rYTPWr8XBHgM1Hcz2DBF6xln8muyGR1SwJWRGqk';
|
|
19
18
|
const options = {
|
|
20
19
|
method: 'GET',
|
|
21
20
|
headers: {
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
getParamOfSelectedMeshes,
|
|
9
9
|
getUserMeshes,
|
|
10
10
|
defaultCameraPosition,
|
|
11
|
+
getBoundingMeshData,
|
|
11
12
|
} from '../helpers';
|
|
12
13
|
import { CAMERAS, MESH_PARAMS } from '../constants';
|
|
13
14
|
import { focusCamera, toggleTurntable } from '../actions';
|
|
@@ -62,15 +63,22 @@ export const prepareCamera = () => {
|
|
|
62
63
|
|
|
63
64
|
export const prepareMaterialCamera = () => {
|
|
64
65
|
const camera = scene.activeCamera;
|
|
65
|
-
const
|
|
66
|
+
const base = scene.getMeshById('node2');
|
|
67
|
+
const sphere = scene.getMeshById('node4');
|
|
66
68
|
camera.position = defaultCameraPosition();
|
|
67
69
|
|
|
68
|
-
if (
|
|
69
|
-
const
|
|
70
|
+
if (base && sphere) {
|
|
71
|
+
const primarySurfaces = [ sphere, base ];
|
|
72
|
+
const meshCenter = getBoundingMeshData(primarySurfaces).center;
|
|
73
|
+
|
|
70
74
|
camera.setTarget(meshCenter);
|
|
71
75
|
camera.alpha = 1.57;
|
|
72
|
-
camera.beta = 1.
|
|
73
|
-
camera.
|
|
76
|
+
camera.beta = 1.35;
|
|
77
|
+
camera.lowerRadiusLimit = 0.3239;
|
|
78
|
+
camera.upperRadiusLimit = 5000;
|
|
79
|
+
camera.minZ = 0.1;
|
|
80
|
+
camera.maxZ = 10000;
|
|
81
|
+
camera.radius = 0.785;
|
|
74
82
|
}
|
|
75
83
|
};
|
|
76
84
|
|
|
@@ -111,6 +111,9 @@ const tweakSceneForShaderball = () => {
|
|
|
111
111
|
if (zAxis) zAxis.isVisible = false;
|
|
112
112
|
if (ground) ground.isVisible = false;
|
|
113
113
|
|
|
114
|
+
const mainMaterial = scene.getMaterialById('material');
|
|
115
|
+
|
|
116
|
+
newMetaDataEntry('selectedMaterial', mainMaterial?.id);
|
|
114
117
|
prepareMaterialCamera();
|
|
115
118
|
props.clearNotifications?.();
|
|
116
119
|
};
|
|
@@ -136,12 +139,9 @@ const initCamera = () => {
|
|
|
136
139
|
const cameraLocation = { x: 0, y: 0, z: 0 };
|
|
137
140
|
newCamera('defaultCamera', cameraLocation, CAMERAS.ArcRotateCamera, cameraMeta);
|
|
138
141
|
|
|
139
|
-
if (props.materialMode) {
|
|
140
|
-
|
|
141
|
-
return;
|
|
142
|
+
if (!props.materialMode) {
|
|
143
|
+
prepareCamera();
|
|
142
144
|
}
|
|
143
|
-
|
|
144
|
-
prepareCamera();
|
|
145
145
|
};
|
|
146
146
|
|
|
147
147
|
const initGUI = () => {
|
package/src/scenes/App/App.js
CHANGED
|
@@ -8,9 +8,10 @@ import { updateCamera, scene } from 'package/helpers';
|
|
|
8
8
|
import Canvas from 'package/Canvas';
|
|
9
9
|
import _ from 'lodash';
|
|
10
10
|
|
|
11
|
-
const materialMode =
|
|
11
|
+
const materialMode = true;
|
|
12
12
|
const previewMode = false;
|
|
13
13
|
const demoScene = false;
|
|
14
|
+
const shaderballGuid = '21-4D80-79E5-E2E5-C1EF-FCED-D3C2-D990-0927-00';
|
|
14
15
|
|
|
15
16
|
const App = () => {
|
|
16
17
|
const [ notifications, setNotifications ] = useState([]);
|
|
@@ -37,10 +38,16 @@ const App = () => {
|
|
|
37
38
|
}, [ notifications, setNotifications ]);
|
|
38
39
|
|
|
39
40
|
const getPreviewURL = useCallback(() => {
|
|
40
|
-
const args = {
|
|
41
|
-
|
|
41
|
+
const args = {
|
|
42
|
+
addNotification,
|
|
43
|
+
rpcGuid: materialMode ? shaderballGuid : guid,
|
|
44
|
+
clearNotifications,
|
|
45
|
+
setPreviewURL,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
fetchDownloadURL(args);
|
|
42
49
|
// eslint-disable-next-line
|
|
43
|
-
}, [ guid ]);
|
|
50
|
+
}, [ guid, materialMode ]);
|
|
44
51
|
|
|
45
52
|
const removeNotification = index => {
|
|
46
53
|
const updatedArray = notifications.filter((item, i) => index !== i);
|