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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**/node_modules
scripts/**/*.js
packages/*/dist
packages/**/*.d.ts
packages/*/src/*-css.ts
Expand Down
2 changes: 1 addition & 1 deletion packages/model-viewer-effects/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ npm install three @google/model-viewer @google/model-viewer-effects
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three@^0.151.0/build/three.module.js"
"three": "https://cdn.jsdelivr.net/npm/three@^0.151.2/build/three.module.min.js"
}
}
</script>
Expand Down
1 change: 1 addition & 0 deletions packages/model-viewer/package-lock.json

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

1 change: 1 addition & 0 deletions packages/model-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"typings": "lib/model-viewer.d.ts",
"types": "lib/model-viewer.d.ts",
"scripts": {
"postinstall": "node ../../scripts/postinstall.js",
"clean": "rm -rf ./lib ./dist",
"prepare": "if [ ! -L './shared-assets' ]; then ln -s ../shared-assets ./shared-assets; fi && ../shared-assets/scripts/fetch-khronos-gltf-samples.sh",
"build": "npm run build:tsc && npm run build:rollup",
Expand Down
2 changes: 1 addition & 1 deletion packages/modelviewer.dev/data/faq.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
{
"name": "How do I avoid duplicating three.js in my bundle?",
"htmlName": "duplication",
"description": "Three.js used to be marked as our dependency, which meant it was duplicated if you used it in another part of your code base too. As of v3.0.2, it is marked as our peer dependency, allowing you to share it. Note that we pin its version due to frequent breaking changes, so you will not have much version flexibility. This can be worked around using npm's --legacy-peer-deps mode, but please do not file issues if you do this, as we can only ensure our tested quality on one version of three.js at a time. If you are working directly with our bundle, then you may prefer to use the <code>model-viewer-no-three.min.js</code> bundle, and bring Three.js manually using an import-map.",
"description": "Three.js used to be marked as our dependency, which meant it was duplicated if you used it in another part of your code base too. As of v3.0.2, it is marked as our peer dependency, allowing you to share it. Note that we pin its version due to frequent breaking changes, so you will not have much version flexibility. This can be worked around using npm's --legacy-peer-deps mode, but please do not file issues if you do this, as we can only ensure our tested quality on one version of three.js at a time. If you are working directly with our bundle, then you may prefer to use the <code>model-viewer-module.min.js</code> bundle, and bring Three.js manually using an import-map.",
"links": [
"<a href='https://docs.npmjs.com/cli/v7/using-npm/config#legacy-peer-deps'>NPM legacy-peer-deps documentation</a>"
]
Expand Down
4 changes: 2 additions & 2 deletions packages/modelviewer.dev/examples/postprocessing/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three@^0.151.0/build/three.module.min.js"
"three": "https://cdn.jsdelivr.net/npm/three@^0.151.2/build/three.module.min.js"
}
}
</script>
Expand Down Expand Up @@ -107,7 +107,7 @@ <h2 class="demo-title">Setup Post Processing</h2>
<script type="importmap-noexecute">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three@0.151.0/build/three.module.js"
"three": "https://cdn.jsdelivr.net/npm/three@^0.151.2/build/three.module.min.js"
}
}
</script>
Expand Down
25 changes: 25 additions & 0 deletions scripts/postinstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const fs = require('fs');
const THREE_REGEX = /three@[~^]?([\dvx*]+(?:[-.](?:[\dx*]+|alpha|beta))*)/gm;
let NEW_THREE_VERSION;
const THREE_PACKAGE_REGEX = /"three": ".*"/g;
fs.readFile('package.json', {encoding: 'utf8'}, (err, data) => {
NEW_THREE_VERSION = `three@${THREE_PACKAGE_REGEX.exec(data)[0].split(' ')[1].replaceAll('"', '')}`;
console.log(NEW_THREE_VERSION);
});

function updateThreeVersion(filePath) {
fs.readFile(filePath, {encoding: 'utf8'}, (err, data) => {
if (err) {
console.error(err);
return;
}
const OLD_THREE_VERSION = THREE_REGEX.exec(data)[0];
data = data.replaceAll(OLD_THREE_VERSION, NEW_THREE_VERSION);
fs.writeFile(filePath, data, {encoding: 'utf8'}, (err) => {
if (err) console.log(err);
});
});
}

updateThreeVersion('../model-viewer-effects/README.md');
updateThreeVersion('../modelviewer.dev/examples/postprocessing/index.html');