Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update dependency three to v0.173.0 #4678

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
"@types/react": "18.3.12",
"@types/react-dom": "18.3.1",
"@types/stats.js": "^0.17.0",
"@types/three": "^0.166.0",
"@types/three": "^0.173.0",
"css-loader": "^7.0.0",
"dotenv-webpack": "^8.0.0",
"html-webpack-plugin": "^5.5.0",
"prettier": "^3.0.0",
"three": "0.166.1",
"three": "0.173.0",
"ts-loader": "9.5.1",
"typescript": "^5.0.4",
"webpack": "^5.76.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/src/utils/InspectNodeUi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class InspectNodeUI {
}
});

this._viewer.addObject3D(gizmo);
this._viewer.addObject3D(gizmo.getHelper());
this._viewer.addObject3D(draggable);

gizmo.attach(draggable);
Expand Down
6 changes: 3 additions & 3 deletions examples/src/utils/LoadGltfUi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class LoadGltfUi {
.name('Show gizmos?')
.onChange(value => {
this._gizmos.forEach(gizmo => {
gizmo.visible = value;
gizmo.getHelper().visible = value;
});
this._viewer.requestRedraw();
});
Expand Down Expand Up @@ -92,9 +92,9 @@ export class LoadGltfUi {

private attachTransformControls(object: THREE.Object3D): void {
const gizmo = new TransformControls(this._viewer.cameraManager.getCamera(), this._viewer.canvas);
gizmo.visible = this._params.transformGizmosVisible;
gizmo.getHelper().visible = this._params.transformGizmosVisible;
gizmo.attach(object);
this._viewer.addObject3D(gizmo);
this._viewer.addObject3D(gizmo.getHelper());
this._gizmos.push(gizmo);

gizmo.addEventListener('change', () => {
Expand Down
2 changes: 1 addition & 1 deletion examples/src/utils/NodeTransformUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class NodeTransformUI {
createAndSetupTransformTool(viewer: Cognite3DViewer<DataSourceType>, model: CogniteCadModel): TransformControls {
const transformControls = new TransformControls(viewer.cameraManager.getCamera(), viewer.domElement);
transformControls.setMode(this.attachTransformControls.mode);
viewer.addObject3D(transformControls);
viewer.addObject3D(transformControls.getHelper());
return transformControls;
}

Expand Down
32 changes: 20 additions & 12 deletions examples/yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"@types/random-seed": "^0.3.5",
"@types/skmeans": "^0.11.7",
"@types/stats": "^0.16.30",
"@types/three": "^0.166.0",
"@types/three": "^0.173.0",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",
"concurrently": "^9.0.0",
Expand Down Expand Up @@ -131,7 +131,7 @@
"resize-observer-polyfill": "^1.5.1",
"shx": "^0.3.4",
"stats.js": "^0.17.0",
"three": "0.166.1",
"three": "0.173.0",
"ts-jest": "29.1.2",
"ts-loader": "^9.5.1",
"tsc-alias": "^1.8.8",
Expand All @@ -146,7 +146,7 @@
},
"peerDependencies": {
"@cognite/sdk": "^7.16.0 || ^8.0.0",
"three": "0.166.1"
"three": "0.173.0"
},
"glslify": {
"transform": [
Expand Down
4 changes: 2 additions & 2 deletions viewer/packages/cad-model/src/wrappers/CadNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import {
StyledTreeIndexSets
} from '@reveal/rendering';

import { Group, Object3D, Plane, Matrix4 } from 'three';
import { Group, Object3D, Plane, Matrix4, Object3DEventMap } from 'three';
import { DrawCallBatchingManager } from '../batching/DrawCallBatchingManager';
import { MultiBufferBatchingManager } from '../batching/MultiBufferBatchingManager';
import { TreeIndexToSectorsMap } from '../utilities/TreeIndexToSectorsMap';

export class CadNode extends Object3D {
export class CadNode extends Object3D<Object3DEventMap & { update: undefined }> {
private readonly _cadModelMetadata: CadModelMetadata;
private readonly _materialManager: CadMaterialManager;
private readonly _sectorRepository: SectorRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '@reveal/pointcloud-styling';

import { Color } from 'three';
import { DMInstanceKey, DMInstanceRef, dmInstanceRefToKey } from '@reveal/utilities';
import { DMInstanceKey, DMInstanceRef, dmInstanceRefToKey, createUint8View } from '@reveal/utilities';

const textureWidth = 10;
const textureHeight = 10;
Expand Down Expand Up @@ -51,18 +51,18 @@ describe(PointCloudObjectAppearanceTexture.name, () => {
appearanceTexture.onBeforeRender();

const rawTexture = appearanceTexture.objectStyleTexture;
const resultRgb = rawTexture.image.data.slice(4 * objectId, 4 * (objectId + 1));
const resultRgb = createUint8View(rawTexture.image.data).slice(4 * objectId, 4 * (objectId + 1));

expect([...resultRgb.values()]).toEqual([...colorBytes, 1]);

// Check that all other objects are unchanged
for (let i = 0; i < rawTexture.image.data.length; i += 4) {
for (let i = 0; i < rawTexture.image.data.byteLength; i += 4) {
// Ignore the modified object
if (i >= 4 * objectId && i < 4 * (objectId + 1)) {
continue;
}

const data = rawTexture.image.data.slice(i, i + 4);
const data = createUint8View(rawTexture.image.data).slice(i, i + 4);
expect([...data.values()]).toStrictEqual([0, 0, 0, 1]);
}
});
Expand All @@ -88,18 +88,18 @@ describe(PointCloudObjectAppearanceTexture.name, () => {
appearanceTexture.onBeforeRender();

const rawTexture = appearanceTexture.objectStyleTexture;
const resultRgb = rawTexture.image.data.slice(4 * objectId, 4 * (objectId + 1));
const resultRgb = createUint8View(rawTexture.image.data).slice(4 * objectId, 4 * (objectId + 1));

expect([...resultRgb.values()]).toEqual([...colorBytes, 1]);

// Check that all other objects are unchanged
for (let i = 0; i < rawTexture.image.data.length; i += 4) {
for (let i = 0; i < rawTexture.image.data.byteLength; i += 4) {
// Ignore the modified object
if (i >= 4 * objectId && i < 4 * (objectId + 1)) {
continue;
}

const data = rawTexture.image.data.slice(i, i + 4);
const data = createUint8View(rawTexture.image.data).slice(i, i + 4);
expect([...data.values()]).toStrictEqual([0, 0, 0, 1]);
}
});
Expand All @@ -125,17 +125,17 @@ describe(PointCloudObjectAppearanceTexture.name, () => {
appearanceTexture.onBeforeRender();

const rawTexture = appearanceTexture.objectStyleTexture;
const resultRgb = rawTexture.image.data.slice(4 * objectId, 4 * (objectId + 1));
const resultRgb = createUint8View(rawTexture.image.data).slice(4 * objectId, 4 * (objectId + 1));

expect([...resultRgb.values()]).toEqual([0, 0, 0, 0]);

for (let i = 0; i < rawTexture.image.data.length; i += 4) {
for (let i = 0; i < rawTexture.image.data.byteLength; i += 4) {
// Ignore the modified object
if (i >= 4 * objectId && i < 4 * (objectId + 1)) {
continue;
}

const data = rawTexture.image.data.slice(i, i + 4);
const data = createUint8View(rawTexture.image.data).slice(i, i + 4);
expect([...data.values()]).toStrictEqual([0, 0, 0, 1]);
}
});
Expand All @@ -161,17 +161,17 @@ describe(PointCloudObjectAppearanceTexture.name, () => {
appearanceTexture.onBeforeRender();

const rawTexture = appearanceTexture.objectStyleTexture;
const resultRgb = rawTexture.image.data.slice(4 * objectId, 4 * (objectId + 1));
const resultRgb = createUint8View(rawTexture.image.data).slice(4 * objectId, 4 * (objectId + 1));

expect([...resultRgb.values()]).toEqual([0, 0, 0, 0]);

for (let i = 0; i < rawTexture.image.data.length; i += 4) {
for (let i = 0; i < rawTexture.image.data.byteLength; i += 4) {
// Ignore the modified object
if (i >= 4 * objectId && i < 4 * (objectId + 1)) {
continue;
}

const data = rawTexture.image.data.slice(i, i + 4);
const data = createUint8View(rawTexture.image.data).slice(i, i + 4);
expect([...data.values()]).toStrictEqual([0, 0, 0, 1]);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from '@reveal/pointcloud-styling';
import { PointCloudObjectIdMaps } from './PointCloudObjectIdMaps';
import { DataSourceType } from '@reveal/data-providers';
import { DMInstanceKey, dmInstanceRefToKey } from '@reveal/utilities/src/fdm/toKey';
import { DMInstanceKey, dmInstanceRefToKey, createUint8View } from '@reveal/utilities';

export class PointCloudObjectAppearanceTexture {
private readonly _objectStyleTexture: THREE.DataTexture;
Expand Down Expand Up @@ -48,7 +48,7 @@ export class PointCloudObjectAppearanceTexture {
}

private setObjectStyle(objectId: number, appearance: CompletePointCloudAppearance): void {
const data = this._objectStyleTexture.image.data;
const data = createUint8View(this._objectStyleTexture.image.data);

const styleData = this.appearanceToRgba(appearance);
data.set(styleData, 4 * objectId);
Expand Down Expand Up @@ -84,7 +84,7 @@ export class PointCloudObjectAppearanceTexture {
const styleData = this.appearanceToRgba(this._defaultAppearance);

for (let i = 0; i < this._width * this._height; i++) {
this._objectStyleTexture.image.data.set(styleData, 4 * i);
createUint8View(this._objectStyleTexture.image.data).set(styleData, 4 * i);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { NodeAppearanceTextureBuilder } from './NodeAppearanceTextureBuilder';

import { TreeIndexNodeCollection, NodeAppearanceProvider } from '@reveal/cad-styling';

import { IndexSet } from '@reveal/utilities';
import { IndexSet, createUint8View } from '@reveal/utilities';

import { Color } from 'three';

Expand Down Expand Up @@ -272,5 +272,5 @@ describe('NodeAppearanceTextureBuilder', () => {
});

function texelsOf(texture: THREE.DataTexture): number[] | undefined {
return Array.from(texture.image.data);
return Array.from(createUint8View(texture.image.data));
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import * as THREE from 'three';

import { IndexSet, determinePowerOfTwoDimensions, NumericRange } from '@reveal/utilities';
import { IndexSet, determinePowerOfTwoDimensions, NumericRange, createUint8View } from '@reveal/utilities';
import { NodeAppearanceProvider, NodeAppearance, DefaultNodeAppearance } from '@reveal/cad-styling';

export class NodeAppearanceTextureBuilder {
Expand All @@ -29,7 +29,7 @@ export class NodeAppearanceTextureBuilder {

this._overrideColorPerTreeIndexTexture = allocateOverrideColorPerTreeIndexTexture(treeIndexCount);
this._overrideColorDefaultAppearanceRgba = new Uint8ClampedArray(
this._overrideColorPerTreeIndexTexture.image.data.length
this._overrideColorPerTreeIndexTexture.image.data.buffer.byteLength
);
this._regularNodesTreeIndices = new IndexSet();
this._ghostedNodesTreeIndices = new IndexSet();
Expand Down Expand Up @@ -107,7 +107,7 @@ export class NodeAppearanceTextureBuilder {
return;
}

const rgba = this._overrideColorPerTreeIndexTexture.image.data;
const rgba = createUint8View(this._overrideColorPerTreeIndexTexture.image.data);
this.populateTexture(rgba);
this.populateNodeSets(rgba);

Expand Down Expand Up @@ -195,7 +195,7 @@ export class NodeAppearanceTextureBuilder {
return;
}

combineRGBA(this._overrideColorPerTreeIndexTexture.image.data, treeIndices, style);
combineRGBA(createUint8View(this._overrideColorPerTreeIndexTexture.image.data), treeIndices, style);
}

private handleStylesChanged() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

import * as THREE from 'three';
import { NumericRange } from '@reveal/utilities';
import { NumericRange, createUint8View } from '@reveal/utilities';
import { NodeTransformProvider } from './NodeTransformProvider';
import { NodeTransformTextureBuilder } from './NodeTransformTextureBuilder';

Expand Down Expand Up @@ -46,5 +46,5 @@ describe('NodeTransformTextureBuilder', () => {
});

function texelsOf(texture: THREE.DataTexture): number[] {
return Array.from(texture.image.data);
return Array.from(createUint8View(texture.image.data));
}
17 changes: 9 additions & 8 deletions viewer/packages/rendering/src/utilities/renderUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

import * as THREE from 'three';
import { createRenderTriangle, WebGLRendererStateHelper } from '@reveal/utilities';
import { createRenderTriangle, WebGLRendererStateHelper, createUint8View } from '@reveal/utilities';
import { CadMaterialManager } from '../CadMaterialManager';
import { RenderMode } from '../rendering/RenderMode';
import { CogniteColors, RevealColors, StyledTreeIndexSets } from './types';
Expand Down Expand Up @@ -159,13 +159,14 @@ function getEDLNeighbourPoints(neighbourCount: number): Float32Array {
function createOutlineColorTexture(): THREE.DataTexture {
const outlineColorBuffer = new Uint8Array(8 * 4);
const outlineColorTexture = new THREE.DataTexture(outlineColorBuffer, 8, 1);
setOutlineColor(outlineColorTexture.image.data, NodeOutlineColor.Black, CogniteColors.Black);
setOutlineColor(outlineColorTexture.image.data, NodeOutlineColor.White, CogniteColors.White);
setOutlineColor(outlineColorTexture.image.data, NodeOutlineColor.Cyan, CogniteColors.Cyan);
setOutlineColor(outlineColorTexture.image.data, NodeOutlineColor.Blue, CogniteColors.Blue);
setOutlineColor(outlineColorTexture.image.data, NodeOutlineColor.Green, RevealColors.Green);
setOutlineColor(outlineColorTexture.image.data, NodeOutlineColor.Red, RevealColors.Red);
setOutlineColor(outlineColorTexture.image.data, NodeOutlineColor.Orange, CogniteColors.Orange);
const colorTextureView = createUint8View(outlineColorTexture.image.data);
setOutlineColor(colorTextureView, NodeOutlineColor.Black, CogniteColors.Black);
setOutlineColor(colorTextureView, NodeOutlineColor.White, CogniteColors.White);
setOutlineColor(colorTextureView, NodeOutlineColor.Cyan, CogniteColors.Cyan);
setOutlineColor(colorTextureView, NodeOutlineColor.Blue, CogniteColors.Blue);
setOutlineColor(colorTextureView, NodeOutlineColor.Green, RevealColors.Green);
setOutlineColor(colorTextureView, NodeOutlineColor.Red, RevealColors.Red);
setOutlineColor(colorTextureView, NodeOutlineColor.Orange, CogniteColors.Orange);
outlineColorTexture.needsUpdate = true;
return outlineColorTexture;
}
Expand Down
Loading
Loading