@archvisioninc/canvas 2.4.9 → 2.5.0
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) => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
1
2
|
import * as BABYLON from 'babylonjs';
|
|
2
3
|
import * as MATERIALS from 'babylonjs-materials';
|
|
3
4
|
import * as BABYLONGUI from 'babylonjs-gui';
|
|
@@ -100,11 +101,9 @@ const initCamera = () => {
|
|
|
100
101
|
z: 0
|
|
101
102
|
};
|
|
102
103
|
newCamera('defaultCamera', cameraLocation, CAMERAS.ArcRotateCamera, cameraMeta);
|
|
103
|
-
if (props.materialMode) {
|
|
104
|
-
|
|
105
|
-
return;
|
|
104
|
+
if (!props.materialMode) {
|
|
105
|
+
prepareCamera();
|
|
106
106
|
}
|
|
107
|
-
prepareCamera();
|
|
108
107
|
};
|
|
109
108
|
const initGUI = () => {
|
|
110
109
|
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
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
1
2
|
import * as BABYLON from 'babylonjs';
|
|
2
3
|
import * as MATERIALS from 'babylonjs-materials';
|
|
3
4
|
import * as BABYLONGUI from 'babylonjs-gui';
|
|
@@ -136,12 +137,9 @@ const initCamera = () => {
|
|
|
136
137
|
const cameraLocation = { x: 0, y: 0, z: 0 };
|
|
137
138
|
newCamera('defaultCamera', cameraLocation, CAMERAS.ArcRotateCamera, cameraMeta);
|
|
138
139
|
|
|
139
|
-
if (props.materialMode) {
|
|
140
|
-
|
|
141
|
-
return;
|
|
140
|
+
if (!props.materialMode) {
|
|
141
|
+
prepareCamera();
|
|
142
142
|
}
|
|
143
|
-
|
|
144
|
-
prepareCamera();
|
|
145
143
|
};
|
|
146
144
|
|
|
147
145
|
const initGUI = () => {
|
package/src/scenes/App/App.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
1
2
|
import { useEffect, useState, useCallback } from 'react';
|
|
2
3
|
import { Notifications } from 'components';
|
|
3
4
|
import { AppContainer, DebugButtons, Button } from './styles';
|
|
@@ -8,9 +9,10 @@ import { updateCamera, scene } from 'package/helpers';
|
|
|
8
9
|
import Canvas from 'package/Canvas';
|
|
9
10
|
import _ from 'lodash';
|
|
10
11
|
|
|
11
|
-
const materialMode =
|
|
12
|
+
const materialMode = true;
|
|
12
13
|
const previewMode = false;
|
|
13
14
|
const demoScene = false;
|
|
15
|
+
const shaderballGuid = '21-4D80-79E5-E2E5-C1EF-FCED-D3C2-D990-0927-00';
|
|
14
16
|
|
|
15
17
|
const App = () => {
|
|
16
18
|
const [ notifications, setNotifications ] = useState([]);
|
|
@@ -37,10 +39,16 @@ const App = () => {
|
|
|
37
39
|
}, [ notifications, setNotifications ]);
|
|
38
40
|
|
|
39
41
|
const getPreviewURL = useCallback(() => {
|
|
40
|
-
const args = {
|
|
41
|
-
|
|
42
|
+
const args = {
|
|
43
|
+
addNotification,
|
|
44
|
+
rpcGuid: materialMode ? shaderballGuid : guid,
|
|
45
|
+
clearNotifications,
|
|
46
|
+
setPreviewURL,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
fetchDownloadURL(args);
|
|
42
50
|
// eslint-disable-next-line
|
|
43
|
-
}, [ guid ]);
|
|
51
|
+
}, [ guid, materialMode ]);
|
|
44
52
|
|
|
45
53
|
const removeNotification = index => {
|
|
46
54
|
const updatedArray = notifications.filter((item, i) => index !== i);
|