@archvisioninc/canvas 2.6.8 → 2.7.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.
@@ -35,11 +35,10 @@ export const prepareCamera = () => {
35
35
  };
36
36
  export const prepareMaterialCamera = () => {
37
37
  const camera = scene.activeCamera;
38
- const base = scene.getMeshById('node2');
39
- const sphere = scene.getMeshById('node4');
38
+ const sphere = scene.getMeshById('node0');
40
39
  camera.position = defaultCameraPosition();
41
- if (base && sphere) {
42
- const primarySurfaces = [sphere, base];
40
+ if (sphere) {
41
+ const primarySurfaces = [sphere];
43
42
  const meshCenter = getBoundingMeshData(primarySurfaces).center;
44
43
  camera.setTarget(meshCenter);
45
44
  camera.alpha = 1.57;
@@ -48,7 +47,7 @@ export const prepareMaterialCamera = () => {
48
47
  camera.upperRadiusLimit = 5000;
49
48
  camera.minZ = 0.1;
50
49
  camera.maxZ = 10000;
51
- camera.radius = 0.785;
50
+ camera.radius = 5;
52
51
  }
53
52
  };
54
53
  export const toggleCameraMode = (orthoCamera, requestedMode) => {
@@ -1,4 +1,3 @@
1
- /* eslint-disable */
2
1
  import { GLTF2 } from 'babylonjs-loaders';
3
2
  import { GIZMOS, GUI, TRANSPARENCY_MODES } from '../constants';
4
3
  import { orthoOptions } from '../enums';
@@ -413,8 +412,9 @@ export const getImageFileFromBuffer = args => {
413
412
  asDataUrl
414
413
  } = args || {};
415
414
  if (_.isEmpty(buffer)) return '';
415
+ if (!_.isObject(buffer) && !_.isArray(buffer)) return buffer;
416
416
  if (asDataUrl) {
417
- const ascii = new Uint8Array(buffer);
417
+ // Convert buffer to data:image/png;base64 string
418
418
  const Uint8ToString = u8a => {
419
419
  if (_.isEmpty(u8a)) return '';
420
420
  const maxChunkSize = 8192;
@@ -425,23 +425,16 @@ export const getImageFileFromBuffer = args => {
425
425
  }
426
426
  return chunks.join('');
427
427
  };
428
+ const ascii = new Uint8Array(buffer);
428
429
  const dataString = btoa(Uint8ToString(ascii));
429
- const blob = new Blob([dataString], {
430
- type: 'image/png'
431
- });
432
- const blobUrl = URL.createObjectURL(blob);
433
- console.log({
434
- dataString,
435
- blob,
436
- blobUrl
437
- });
438
- return blobUrl;
430
+ const dataUrl = `data:image/png;base64,${dataString}`;
431
+ return dataUrl;
439
432
  }
440
433
  const blob = new Blob([buffer], {
441
434
  type: 'image/png'
442
435
  });
443
- const url = URL.createObjectURL(blob);
444
- return url;
436
+ const blobUrl = URL.createObjectURL(blob);
437
+ return blobUrl;
445
438
  };
446
439
  export const getTextureUrl = args => {
447
440
  const {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archvisioninc/canvas",
3
- "version": "2.6.8",
3
+ "version": "2.7.0",
4
4
  "private": false,
5
5
  "main": "dist/Canvas.js",
6
6
  "module": "dist/Canvas.js",
@@ -63,12 +63,11 @@ export const prepareCamera = () => {
63
63
 
64
64
  export const prepareMaterialCamera = () => {
65
65
  const camera = scene.activeCamera;
66
- const base = scene.getMeshById('node2');
67
- const sphere = scene.getMeshById('node4');
66
+ const sphere = scene.getMeshById('node0');
68
67
  camera.position = defaultCameraPosition();
69
68
 
70
- if (base && sphere) {
71
- const primarySurfaces = [ sphere, base ];
69
+ if (sphere) {
70
+ const primarySurfaces = [ sphere ];
72
71
  const meshCenter = getBoundingMeshData(primarySurfaces).center;
73
72
 
74
73
  camera.setTarget(meshCenter);
@@ -78,7 +77,7 @@ export const prepareMaterialCamera = () => {
78
77
  camera.upperRadiusLimit = 5000;
79
78
  camera.minZ = 0.1;
80
79
  camera.maxZ = 10000;
81
- camera.radius = 0.785;
80
+ camera.radius = 5;
82
81
  }
83
82
  };
84
83
 
@@ -1,4 +1,3 @@
1
- /* eslint-disable */
2
1
  import { GLTF2 } from 'babylonjs-loaders';
3
2
  import { GIZMOS, GUI, TRANSPARENCY_MODES } from '../constants';
4
3
  import { orthoOptions } from '../enums';
@@ -471,10 +470,10 @@ export const getImageFileFromBuffer = args => {
471
470
  const { buffer, asDataUrl } = args || {};
472
471
 
473
472
  if (_.isEmpty(buffer)) return '';
473
+ if (!_.isObject(buffer) && !_.isArray(buffer)) return buffer;
474
474
 
475
475
  if (asDataUrl) {
476
- const ascii = new Uint8Array(buffer);
477
-
476
+ // Convert buffer to data:image/png;base64 string
478
477
  const Uint8ToString = u8a => {
479
478
  if (_.isEmpty(u8a)) return '';
480
479
 
@@ -489,18 +488,17 @@ export const getImageFileFromBuffer = args => {
489
488
  return chunks.join('');
490
489
  };
491
490
 
491
+ const ascii = new Uint8Array(buffer);
492
492
  const dataString = btoa(Uint8ToString(ascii));
493
- const blob = new Blob([ dataString ], { type: 'image/png' });
494
- const blobUrl = URL.createObjectURL(blob);
493
+ const dataUrl = `data:image/png;base64,${dataString}`;
495
494
 
496
- console.log({ dataString, blob, blobUrl });
497
- return blobUrl;
495
+ return dataUrl;
498
496
  }
499
497
 
500
498
  const blob = new Blob([ buffer ], { type: 'image/png' });
501
- const url = URL.createObjectURL(blob);
499
+ const blobUrl = URL.createObjectURL(blob);
502
500
 
503
- return url;
501
+ return blobUrl;
504
502
  };
505
503
 
506
504
  export const getTextureUrl = args => {
@@ -12,7 +12,7 @@ import _ from 'lodash';
12
12
  const materialMode = true;
13
13
  const previewMode = false;
14
14
  const demoScene = false;
15
- const shaderballGuid = '21-4D80-79E5-E2E5-C1EF-FCED-D3C2-D990-0927-00';
15
+ const shaderballGuid = '21-D640-6334-86DD-4B8D-EDE8-3888-9769-DF26-00';
16
16
 
17
17
  const serializedResponseData = {
18
18
  albedoColor: '#004BA6',