Skip to content

Commit

Permalink
Fix OrbitControls in the test:ci for GH
Browse files Browse the repository at this point in the history
  • Loading branch information
kieftrav committed Oct 4, 2024
1 parent 87fb19f commit bf34584
Showing 1 changed file with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@ import {
} from 'three'
import { useEffect, useLayoutEffect, useRef } from 'react'
import { Histogram } from './Histogram.js'
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
import { pointColor } from './../helpers/pointColor.js'
import { SortedSetUnion } from './../helpers/SortedSet.js'

// Shim for test:ci in GH needs this to work
let OrbitControls = null;
import("three/addons/controls/OrbitControls.js").then((module) => {
OrbitControls = module.OrbitControls;
})

// Shim for node.js testing
let glContext = null
if (!process.browser) {
// HAD TO COMMENT OUT TO GET test:ci working in PR on GH
// const glc = require('gl') // (1,1); //headless-gl
// glContext = glc(1, 1)

window.requestAnimationFrame = () => {
// needs to be stubbed out for animate() to work
}
Expand Down Expand Up @@ -147,13 +148,17 @@ export const Cube = ({ annotations, tool, viewer }) => {
threeRef.current.renderer.setPixelRatio(window.devicePixelRatio)
threeRef.current.renderer.setSize(width, width)

threeRef.current.orbit = new OrbitControls(
threeRef.current.camera,
threeRef.current.renderer.domElement,
);
threeRef.current.orbit.enableDamping = false;
threeRef.current.orbit.enableZoom = true;
threeRef.current.orbit.enablePan = false;
if (OrbitControls) {
threeRef.current.orbit = new OrbitControls(
threeRef.current.camera,
threeRef.current.renderer.domElement,
);
threeRef.current.orbit.enableDamping = false;
threeRef.current.orbit.enableZoom = true;
threeRef.current.orbit.enablePan = false;
} else {
console.log('OrbitControls are not available')
}

// View Axes
const half = viewer.base / 2
Expand Down

0 comments on commit bf34584

Please sign in to comment.