Skip to content

Commit

Permalink
chore(deps): update dependency three to v0.165.0 (#4560)
Browse files Browse the repository at this point in the history
* chore(deps): update dependency three to v0.165.0

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Håkon Flatval <[email protected]>
  • Loading branch information
renovate[bot] and haakonflatval-cognite authored Jun 5, 2024
1 parent 1eb71a4 commit b35aab8
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 159 deletions.
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.3",
"@types/react-dom": "18.3.0",
"@types/stats.js": "^0.17.0",
"@types/three": "^0.164.0",
"@types/three": "^0.165.0",
"css-loader": "^7.0.0",
"dotenv-webpack": "^8.0.0",
"html-webpack-plugin": "^5.5.0",
"prettier": "^3.0.0",
"three": "0.164.1",
"three": "0.165.0",
"ts-loader": "9.5.1",
"typescript": "^5.0.4",
"webpack": "^5.76.0",
Expand Down
18 changes: 9 additions & 9 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 @@ -95,7 +95,7 @@
"@types/random-seed": "^0.3.5",
"@types/skmeans": "^0.11.7",
"@types/stats": "^0.16.30",
"@types/three": "^0.164.0",
"@types/three": "^0.165.0",
"@types/tween.js": "^18.6.1",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",
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.164.1",
"three": "0.165.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.164.1"
"three": "0.165.0"
},
"glslify": {
"transform": [
Expand Down
31 changes: 16 additions & 15 deletions viewer/packages/cad-model/src/picking/PickingHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from '@reveal/rendering';
import { SceneHandler, WebGLRendererStateHelper } from '@reveal/utilities';
import { CadNode } from '../wrappers/CadNode';
import { readPixelsFromTargetAsync } from './readPixelsFromTargetAsync';
import { Mutex } from 'async-mutex';

type PickingInput = {
Expand Down Expand Up @@ -90,7 +89,7 @@ export class PickingHandler {
public async intersectCadNodes(
cadNodes: CadNode[],
input: IntersectInput,
async = true
shouldRunAsync = true
): Promise<IntersectCadNodesResult[]> {
const results: IntersectCadNodesResult[] = [];

Expand Down Expand Up @@ -119,10 +118,10 @@ export class PickingHandler {
// Make current CadNode visible & hide others
visibleCadNodes.forEach(p => (p.visible = false));
cadNodeData.cadNode.visible = true;
const treeIndex = await this.intersectCadNodeTreeIndex(cadNodeData.cadNode, input, async);
const treeIndex = await this.intersectCadNodeTreeIndex(cadNodeData.cadNode, input, shouldRunAsync);
if (treeIndex) {
// Assuming we have depth anywhere we hit a treeIndex
const depthResult = await this.intersectCadNodeDepth(depthInput, async);
const depthResult = await this.intersectCadNodeDepth(depthInput, shouldRunAsync);
const result: IntersectCadNodesResult = {
distance: depthResult.distance,
point: depthResult.point,
Expand Down Expand Up @@ -188,9 +187,9 @@ export class PickingHandler {
}
}

private async intersectCadNodeDepth(input: PickingInput, async: boolean) {
private async intersectCadNodeDepth(input: PickingInput, shouldRunAsync: boolean) {
const { camera } = input;
const depth = await this.pickDepth(input, async);
const depth = await this.pickDepth(input, shouldRunAsync);

const viewZ = this.perspectiveDepthToViewZ(depth, camera.near, camera.far);
const point = this.getPosition(input, viewZ);
Expand All @@ -204,7 +203,7 @@ export class PickingHandler {
private async intersectCadNodeTreeIndex(
cadNode: CadNode,
input: IntersectInput,
async: boolean
shouldRunAsync: boolean
): Promise<number | undefined> {
const { camera, normalizedCoords, renderer, domElement } = input;
const pickingScene = new THREE.Scene();
Expand All @@ -218,14 +217,14 @@ export class PickingHandler {
cadNodes: [],
cadNode
};
const treeIndex = await this.pickTreeIndex(pickInput, async);
const treeIndex = await this.pickTreeIndex(pickInput, shouldRunAsync);
if (treeIndex === undefined) {
return undefined;
}
return treeIndex;
}

private async pickTreeIndex(input: TreeIndexPickingInput, async: boolean): Promise<number | undefined> {
private async pickTreeIndex(input: TreeIndexPickingInput, shouldRunAsync: boolean): Promise<number | undefined> {
const { cadNode } = input;
const previousRenderMode = cadNode.renderMode;
cadNode.renderMode = RenderMode.TreeIndex;
Expand All @@ -236,7 +235,7 @@ export class PickingHandler {
this._treeIndexRenderPipeline,
this._clearColor,
this._clearAlpha,
async
shouldRunAsync
);
} finally {
cadNode.renderMode = previousRenderMode;
Expand All @@ -255,7 +254,7 @@ export class PickingHandler {
return (near * far) / ((far - near) * invClipZ - far);
}

private async pickDepth(input: PickingInput, async: boolean): Promise<number> {
private async pickDepth(input: PickingInput, shouldRunAsync: boolean): Promise<number> {
const { cadNodes } = input;
const previousRenderMode = cadNodes[0].renderMode;
cadNodes.forEach(cadeNode => (cadeNode.renderMode = RenderMode.Depth));
Expand All @@ -264,7 +263,7 @@ export class PickingHandler {
this._depthRenderPipeline,
this._clearColor,
this._clearAlpha,
async
shouldRunAsync
);
cadNodes.forEach(cadeNode => (cadeNode.renderMode = previousRenderMode));

Expand All @@ -287,7 +286,7 @@ export class PickingHandler {
renderPipeline: RenderPipelineProvider,
clearColor: THREE.Color,
clearAlpha: number,
async: boolean
shouldRunAsync: boolean
) {
const { renderTarget, pixelBuffer } = this._pickPixelColorStorage;
const { camera, normalizedCoords, renderer, domElement } = input;
Expand All @@ -305,10 +304,12 @@ export class PickingHandler {
try {
stateHelper.setClearColor(clearColor, clearAlpha);
this._pipelineExecutor.render(renderPipeline, pickCamera);
readPixelsPromise = readPixelsFromTargetAsync(renderer, renderTarget, 0, 0, 1, 1, pixelBuffer, !async);
readPixelsPromise = shouldRunAsync
? renderer.readRenderTargetPixelsAsync(renderTarget, 0, 0, 1, 1, pixelBuffer).then(() => {})
: Promise.resolve(renderer.readRenderTargetPixels(renderTarget, 0, 0, 1, 1, pixelBuffer));
} finally {
// Note! State is reset before promise is resolved as there might be rendering happening between
// "now" and when the result from readPixelsFromTargetAsync is ready
// "now" and when the result from readRenderTargetPixelsAsync is ready
stateHelper.resetState();
}
await readPixelsPromise;
Expand Down
119 changes: 0 additions & 119 deletions viewer/packages/cad-model/src/picking/readPixelsFromTargetAsync.ts

This file was deleted.

5 changes: 5 additions & 0 deletions viewer/test-utilities/src/autoMockWebGLRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ function autoMockGLRenderer(
renderer.setup(instance => instance.getScissorTest()).returns(true);
renderer.setup(instance => instance.setScissorTest(It.IsAny())).returns();
renderer.setup(instance => instance.setSize(It.IsAny(), It.IsAny())).returns();
renderer
.setup(instance =>
instance.readRenderTargetPixelsAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())
)
.returns(Promise.resolve(new Uint8Array(4)));
renderer.setup(instance => instance.renderLists).returns(renderLists.object());
renderer.setup(instance => instance.state).returns(webglState.object());
renderer.setup(instance => instance.extensions).returns(new Mock<WebGLExtensions>().object());
Expand Down
22 changes: 11 additions & 11 deletions viewer/yarn.lock

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

0 comments on commit b35aab8

Please sign in to comment.