Skip to content
Merged
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
29 changes: 29 additions & 0 deletions config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,32 @@ module.exports = function override(webpackConfig) {

return webpackConfig;
};

// three is ESM-only since r186 (`three.cjs` is a deprecated shim re-exporting `three.module.js`),
// so Jest has to convert it to CommonJS and should resolve `three` straight to its ES module build
module.exports.jest = function overrideJest(jestConfig) {
jestConfig.transformIgnorePatterns = [
'[/\\\\]node_modules[/\\\\](?!three[/\\\\]).+\\.(js|jsx|mjs|cjs|ts|tsx)$',
'^.+\\.module\\.(css|sass|scss)$'
];

// only the module syntax needs converting, Node runs the rest of three natively
jestConfig.transform = {
'[/\\\\]node_modules[/\\\\]three[/\\\\].+\\.js$': [
require.resolve('babel-jest'),
{
babelrc: false,
configFile: false,
plugins: [require.resolve('@babel/plugin-transform-modules-commonjs')]
}
],
...jestConfig.transform
};

jestConfig.moduleNameMapper = {
...jestConfig.moduleNameMapper,
'^three$': '<rootDir>/node_modules/three/build/three.module.js'
};

return jestConfig;
};
42 changes: 17 additions & 25 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"set-interval-async": "^3.0.3",
"signals": "^1.0.0",
"split-grid": "^1.0.11",
"three": "^0.181.1",
"three": "^0.186.1",
Comment thread
martastn marked this conversation as resolved.
"throttle-debounce": "^5.0.2",
"typescript": "^5.2.2",
"use-interval": "^1.4.0",
Expand Down Expand Up @@ -210,7 +210,7 @@
"@types/react": "^19.2.7",
"@types/react-async-script": "^1.2.5",
"@types/selenium-webdriver": "^4.35.4",
"@types/three": "^0.177.0",
"@types/three": "^0.186.0",
"cross-env": "^10.1.0",
"dependency-cruiser": "^17.3.1",
"eslint-plugin-simple-import-sort": "^12.1.1",
Expand Down
3 changes: 2 additions & 1 deletion src/ThreeEditor/Simulation/Materials/SimulationMaterial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ export default class SimulationMaterial
}: SimulationMaterialJSON
): SimulationMaterial {
const material = new SimulationMaterial(editor, name, sanitizedName, icru, density);
material.uuid = uuid;
// @types/three marks Material.uuid as readonly, but three keeps it writable and we restore it on load
(material as { uuid: string }).uuid = uuid;
material.customStoppingPower = customStoppingPower ?? false;
material.renderProps = renderProps;
material.applyRenderProps();
Expand Down
7 changes: 4 additions & 3 deletions src/ThreeEditor/js/viewport/ViewportManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,11 +587,12 @@ function ViewManager(editor) {

// animations

const clock = new THREE.Clock(); // only used for animations
const timer = new THREE.Timer(); // only used for animations

function animate() {
function animate(timestamp) {
const { mixer } = editor;
const delta = clock.getDelta();
timer.update(timestamp);
const delta = timer.getDelta();

let needsUpdate = false;

Expand Down
Loading