Skip to content

Commit

Permalink
feat: vendor threejs files (#247)
Browse files Browse the repository at this point in the history
Copy the example files we depended on from an older version of threejs into a vendor directory and apply the rollup replace pieces directly to it.
This allows us to update to a newer version of threejs so that npm audit --production no longer produces any issues. We can't upgrade to newer versions of threejs until we update our tooling and likely start transpiling threejs as well, because by default it starts including new JS features in the build files.

Fixes #244.
  • Loading branch information
gkatsev authored Aug 31, 2021
1 parent 734d4b4 commit 6a76537
Show file tree
Hide file tree
Showing 12 changed files with 1,947 additions and 163 deletions.
158 changes: 86 additions & 72 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"ignore": [
"dist",
"docs",
"vendor",
"test/dist"
]
},
Expand All @@ -80,7 +81,7 @@
"dependencies": {
"@babel/runtime": "^7.14.5",
"global": "^4.4.0",
"three": "0.93.0",
"three": "0.125.2",
"video.js": "^6 || ^7",
"webvr-polyfill": "0.10.12"
},
Expand Down
13 changes: 0 additions & 13 deletions scripts/rollup-example-resolver.js

This file was deleted.

52 changes: 0 additions & 52 deletions scripts/rollup-replace.js

This file was deleted.

19 changes: 1 addition & 18 deletions scripts/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
const generate = require('videojs-generate-rollup-config');
const replace = require('./rollup-replace');
const exampleResolver = require('./rollup-example-resolver');

// see https://github.com/videojs/videojs-generate-rollup-config
// for options
const options = {
primedPlugins(defaults) {
return Object.assign(defaults, {exampleResolver,replace});
},
plugins(defaults) {
defaults.module.unshift('exampleResolver')

// add replace just after json for each build
Object.keys(defaults).forEach((type) => {
defaults[type].splice(defaults[type].indexOf('json') + 1, '0', 'replace');
});

return defaults;
}
};
const config = generate(options);
const config = generate({});

// Add additional builds/customization here!

Expand Down
2 changes: 1 addition & 1 deletion src/canvas-player-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class CanvasPlayerControls extends videojs.EventTarget {
}

// We want the same behavior in Desktop for VR360 and standard player
if (e.type == 'mouseup') {
if (e.type === 'mouseup') {
this.togglePlay();
}

Expand Down
4 changes: 2 additions & 2 deletions src/orbit-orientation-controls.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as THREE from 'three';
import OrbitControls from 'three/examples/js/controls/OrbitControls.js';
import DeviceOrientationControls from 'three/examples/js/controls/DeviceOrientationControls.js';
import OrbitControls from '../vendor/three/OrbitControls.js';
import DeviceOrientationControls from '../vendor/three/DeviceOrientationControls.js';

/**
* Convert a quaternion to an angle
Expand Down
Loading

0 comments on commit 6a76537

Please sign in to comment.