Sfoglia il codice sorgente

Minor fixes and upgrades

master
Palash Bansal 2 anni fa
parent
commit
f4106eb845
Nessun account collegato all'indirizzo email del committer

+ 1
- 0
.github/workflows/deploy-pages.yml Vedi File

@@ -42,6 +42,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: '**/package-lock.json' # https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-data
- run: npm ci # this will also run `npm run prepare` which will build
- run: npm run docs
- run: mkdir _site

+ 34
- 44
package-lock.json Vedi File

@@ -1,12 +1,12 @@
{
"name": "threepipe",
"version": "0.0.14",
"version": "0.0.13",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "threepipe",
"version": "0.0.14",
"version": "0.0.13",
"license": "Apache-2.0",
"dependencies": {
"@types/three": "https://github.com/repalash/three-ts-types/releases/download/v0.152.1014/package.tgz",
@@ -18,6 +18,7 @@
"@rollup/plugin-commonjs": "^25.0.0",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-terser": "^0.4.3",
"@rollup/plugin-typescript": "^11.1.1",
"@types/stats.js": "^0.17.0",
@@ -37,7 +38,6 @@
"rollup-plugin-glsl": "^1.3.0",
"rollup-plugin-license": "^3.0.1",
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-replace": "^2.2.0",
"stats.js": "^0.17.0",
"three": "https://github.com/repalash/three.js-modded/releases/download/v0.152.2012/package.tgz",
"tslib": "^2.5.0",
@@ -443,6 +443,27 @@
}
}
},
"node_modules/@rollup/plugin-replace": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-5.0.2.tgz",
"integrity": "sha512-M9YXNekv/C/iHHK+cvORzfRYfPbq0RDD8r0G+bMiTXjNGKulPnCT9O3Ss46WfhI6ZOCgApOP7xAdmCQJ+U2LAA==",
"dev": true,
"dependencies": {
"@rollup/pluginutils": "^5.0.1",
"magic-string": "^0.27.0"
},
"engines": {
"node": ">=14.0.0"
},
"peerDependencies": {
"rollup": "^1.20.0||^2.0.0||^3.0.0"
},
"peerDependenciesMeta": {
"rollup": {
"optional": true
}
}
},
"node_modules/@rollup/plugin-terser": {
"version": "0.4.3",
"resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.4.3.tgz",
@@ -8455,26 +8476,6 @@
"postcss": "8.x"
}
},
"node_modules/rollup-plugin-replace": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/rollup-plugin-replace/-/rollup-plugin-replace-2.2.0.tgz",
"integrity": "sha512-/5bxtUPkDHyBJAKketb4NfaeZjL5yLZdeUihSfbF2PQMz+rSTEb8ARKoOl3UBT4m7/X+QOXJo3sLTcq+yMMYTA==",
"deprecated": "This module has moved and is now available at @rollup/plugin-replace. Please update your dependencies. This version is no longer maintained.",
"dev": true,
"dependencies": {
"magic-string": "^0.25.2",
"rollup-pluginutils": "^2.6.0"
}
},
"node_modules/rollup-plugin-replace/node_modules/magic-string": {
"version": "0.25.9",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz",
"integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==",
"dev": true,
"dependencies": {
"sourcemap-codec": "^1.4.8"
}
},
"node_modules/rollup-pluginutils": {
"version": "2.8.2",
"resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz",
@@ -10687,6 +10688,16 @@
"resolve": "^1.22.1"
}
},
"@rollup/plugin-replace": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-5.0.2.tgz",
"integrity": "sha512-M9YXNekv/C/iHHK+cvORzfRYfPbq0RDD8r0G+bMiTXjNGKulPnCT9O3Ss46WfhI6ZOCgApOP7xAdmCQJ+U2LAA==",
"dev": true,
"requires": {
"@rollup/pluginutils": "^5.0.1",
"magic-string": "^0.27.0"
}
},
"@rollup/plugin-terser": {
"version": "0.4.3",
"resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.4.3.tgz",
@@ -16458,27 +16469,6 @@
"style-inject": "^0.3.0"
}
},
"rollup-plugin-replace": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/rollup-plugin-replace/-/rollup-plugin-replace-2.2.0.tgz",
"integrity": "sha512-/5bxtUPkDHyBJAKketb4NfaeZjL5yLZdeUihSfbF2PQMz+rSTEb8ARKoOl3UBT4m7/X+QOXJo3sLTcq+yMMYTA==",
"dev": true,
"requires": {
"magic-string": "^0.25.2",
"rollup-pluginutils": "^2.6.0"
},
"dependencies": {
"magic-string": {
"version": "0.25.9",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz",
"integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==",
"dev": true,
"requires": {
"sourcemap-codec": "^1.4.8"
}
}
}
},
"rollup-pluginutils": {
"version": "2.8.2",
"resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz",

+ 1
- 1
package.json Vedi File

@@ -98,7 +98,7 @@
"typescript": "^5.0.4",
"typescript-plugin-css-modules": "^5.0.1",
"uiconfig.js": "^0.0.6",
"rollup-plugin-replace": "^2.2.0",
"@rollup/plugin-replace": "^5.0.2",
"popmotion": "^11.0.5"
},
"dependencies": {

+ 3
- 3
plugins/extra-importers/package.json Vedi File

@@ -1,7 +1,7 @@
{
"name": "@threepipe/plugins-extra-importers",
"description": "Extra Threepipe plugins for importing several file types.",
"version": "0.1.0",
"version": "0.1.1",
"devDependencies": {
},
"dependencies": {
@@ -17,12 +17,12 @@
],
"replace": {
"dependencies": {
"threepipe": "^0.0.14"
"threepipe": "^0.0.13"
}
}
},
"type": "module",
"main": "dist/index.js",
"main": "dist/index.mjs",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [

+ 17
- 15
plugins/extra-importers/rollup.config.mjs Vedi File

@@ -5,10 +5,10 @@ import resolve from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import license from 'rollup-plugin-license'
import packageJson from './package.json' assert {type: 'json'};
import path from 'path'
import {fileURLToPath} from 'url';
import path from 'node:path'
import {fileURLToPath} from 'node:url';
import postcss from 'rollup-plugin-postcss'
import replace from 'rollup-plugin-replace'
import replace from '@rollup/plugin-replace'
import terser from "@rollup/plugin-terser";

const __filename = fileURLToPath(import.meta.url);
@@ -47,22 +47,24 @@ export default {
isProduction && terser()
]
},
{
file: './dist/index.js',
...settings,
name: name,
format: 'umd',
plugins: [
isProduction && terser()
]
}
// {
// file: './dist/index.js',
// ...settings,
// name: name,
// format: 'umd',
// plugins: [
// isProduction && terser()
// ]
// }
],
external: Object.keys(settings.globals),
plugins: [
replace({
// If you would like DEV messages, specify 'development'
// Otherwise use 'production'
'process.env.NODE_ENV': JSON.stringify('production') // for tippy.js
'from \'three\'': 'from \'threepipe\'',
delimiters: ['', ''],
}),
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
postcss({
modules: false,

+ 4
- 1
plugins/extra-importers/tsconfig.json Vedi File

@@ -28,7 +28,10 @@
"es2020",
"esnext",
"dom"
]
],
"paths": {
"three": ["threepipe"]
}
},
"include": [
"src/**/*"

+ 7
- 4
plugins/plugin-template-rollup/rollup.config.mjs Vedi File

@@ -8,7 +8,7 @@ import packageJson from './package.json' assert {type: 'json'};
import path from 'path'
import {fileURLToPath} from 'url';
import postcss from 'rollup-plugin-postcss'
import replace from 'rollup-plugin-replace'
import replace from '@rollup/plugin-replace'
import terser from "@rollup/plugin-terser";

const __filename = fileURLToPath(import.meta.url);
@@ -20,6 +20,7 @@ const isProduction = process.env.NODE_ENV === 'production'

const settings = {
globals: {
"three": "threepipe", // just incase someone uses three
"threepipe": "threepipe",
"@threepipe/plugin-tweakpane": "@threepipe/plugin-tweakpane"
},
@@ -60,9 +61,11 @@ export default {
external: Object.keys(settings.globals),
plugins: [
replace({
// If you would like DEV messages, specify 'development'
// Otherwise use 'production'
'process.env.NODE_ENV': JSON.stringify('production') // for tippy.js
'from \'three\'': 'from \'threepipe\'',
delimiters: ['', ''],
}),
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
postcss({
modules: false,

+ 8
- 5
plugins/tweakpane-editor/rollup.config.mjs Vedi File

@@ -8,7 +8,7 @@ import packageJson from './package.json' assert {type: 'json'};
import path from 'path'
import {fileURLToPath} from 'url';
import postcss from 'rollup-plugin-postcss'
import replace from 'rollup-plugin-replace'
import replace from '@rollup/plugin-replace'
import terser from "@rollup/plugin-terser";

const __filename = fileURLToPath(import.meta.url);
@@ -20,8 +20,9 @@ const isProduction = process.env.NODE_ENV === 'production'

const settings = {
globals: {
"three": "threepipe",
"threepipe": "threepipe",
"@threepipe/plugin-tweakpane": "@threepipe/plugin-tweakpane"
"@threepipe/plugin-tweakpane": "@threepipe/plugin-tweakpane" // would be used in externals
},
sourcemap: true
}
@@ -60,9 +61,11 @@ export default {
external: Object.keys(settings.globals),
plugins: [
replace({
// If you would like DEV messages, specify 'development'
// Otherwise use 'production'
'process.env.NODE_ENV': JSON.stringify('production') // for tippy.js
'from \'three\'': 'from \'threepipe\'',
delimiters: ['', ''],
}),
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
postcss({
modules: false,

+ 7
- 4
plugins/tweakpane/rollup.config.mjs Vedi File

@@ -9,7 +9,7 @@ import path from 'path'
import {fileURLToPath} from 'url';
import terser from "@rollup/plugin-terser";
import postcss from 'rollup-plugin-postcss'
import replace from 'rollup-plugin-replace'
import replace from '@rollup/plugin-replace'

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
@@ -20,6 +20,7 @@ const isProduction = process.env.NODE_ENV === 'production'

const settings = {
globals: {
"three": "threepipe",
"threepipe": "threepipe"
},
sourcemap: true
@@ -59,9 +60,11 @@ export default {
external: Object.keys(settings.globals),
plugins: [
replace({
// If you would like DEV messages, specify 'development'
// Otherwise use 'production'
'process.env.NODE_ENV': JSON.stringify('production') // for tippy.js
'from \'three\'': 'from \'threepipe\'',
delimiters: ['', ''],
}),
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
postcss({
modules: false,

+ 18
- 12
rollup.config.mjs Vedi File

@@ -7,10 +7,9 @@ import license from 'rollup-plugin-license'
import packageJson from './package.json' assert {type: 'json'};
import path from 'path'
import {fileURLToPath} from 'url';
import terser from "@rollup/plugin-terser";
import postcss from 'rollup-plugin-postcss'
import glsl from "rollup-plugin-glsl"
import replace from "rollup-plugin-replace";
import replace from "@rollup/plugin-replace";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
@@ -45,21 +44,28 @@ export default {
// preserveModulesRoot: 'src', // optional but useful to create a more plain folder structure
format: 'es'
},
{
file: browser,
...settings,
name: name,
format: 'umd',
plugins: [
isProduction && terser()
]
}
// {
// file: browser,
// ...settings,
// name: name,
// format: 'umd',
// plugins: [
// isProduction && terser()
// ]
// }
],
external: [],
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify( 'production' )
'process.env.NODE_ENV': JSON.stringify( 'production' ),
}),
// replace({
// exclude: 'src/**',
// delimiters: ['', ''],
// values:{
// 'from \'three\'': 'from \'threepipe\'',
// },
// }),
glsl({ // todo: minify glsl.
include: "src/**/*.glsl"
}),

+ 1
- 1
src/assetmanager/AssetManager.ts Vedi File

@@ -357,7 +357,7 @@ export class AssetManager extends EventDispatcher<BaseEvent&{data: ImportResult}
}, ['exr'], ['image/x-exr'], false),

new Importer(FBXLoader, ['fbx'], ['model/fbx'], true),
new Importer(ZipLoader, ['zip'], ['application/zip'], true),
new Importer(ZipLoader, ['zip', 'glbz', 'gltfz'], ['application/zip', 'data:model/gltf+zip'], true), // gltfz and glbz are invented zip files with gltf/glb inside along with resources

new Importer(OBJLoader2 as any as Class<ILoader>, ['obj'], ['model/obj'], true),
new Importer(MTLLoader2 as any as Class<ILoader>, ['mtl'], ['model/mtl'], false),

+ 2
- 2
src/assetmanager/import/OBJLoader2.ts Vedi File

@@ -455,7 +455,7 @@ class OBJLoader2 extends Loader implements ILoader{
loader.setPath( this.path );
loader.setRequestHeader( this.requestHeader );
loader.setWithCredentials( this.withCredentials );
this.currentUrl = url;
scope.currentUrl = url;
loader.load( url, async function ( text ) {

try {
@@ -478,7 +478,7 @@ class OBJLoader2 extends Loader implements ILoader{

}

this.currentUrl = undefined;
scope.currentUrl = undefined;

}, onProgress, onError );


+ 33
- 15
src/three/math/Box3B.ts Vedi File

@@ -9,31 +9,49 @@ export class Box3B extends Box3 {
if (object.userData?.bboxVisible === false) return this
if (!object.visible && ignoreInvisible) return this

// copied the whole function from three.js to pass in ignoreInvisible

// Computes the world-axis-aligned bounding box of an object (including its children),
// accounting for both the object's, and children's, world transforms

object.updateWorldMatrix(false, false)

const geometry = (object as Mesh).geometry
// InstancedMesh has boundingBox = null, so it can be computed
if ((object as any).boundingBox !== undefined) {

if (geometry !== undefined) {
if (precise && geometry.attributes != undefined && geometry.attributes.position !== undefined) {
const position = geometry.attributes.position as any as BufferAttribute | InterleavedBufferAttribute
for (let i = 0, l = position.count; i < l; i++) {
this._vector.fromBufferAttribute(position, i).applyMatrix4(object.matrixWorld)
this.expandByPoint(this._vector)
}
} else {
if (geometry.boundingBox === null)
geometry.computeBoundingBox()
Box3B._box.copy(geometry.boundingBox!)
Box3B._box.applyMatrix4(object.matrixWorld)
if ((object as any).boundingBox === null) {

this.union(Box3B._box)
(object as any).computeBoundingBox()

}
}

Box3B._box.copy((object as any).boundingBox)
Box3B._box.applyMatrix4(object.matrixWorld)

this.union(Box3B._box)

} else {

const geometry = (object as Mesh).geometry

if (geometry !== undefined) {
if (precise && geometry.attributes != undefined && geometry.attributes.position !== undefined) {
const position = geometry.attributes.position as any as BufferAttribute | InterleavedBufferAttribute
for (let i = 0, l = position.count; i < l; i++) {
this._vector.fromBufferAttribute(position, i).applyMatrix4(object.matrixWorld)
this.expandByPoint(this._vector)
}
} else {
if (geometry.boundingBox === null)
geometry.computeBoundingBox()
Box3B._box.copy(geometry.boundingBox!)
Box3B._box.applyMatrix4(object.matrixWorld)

this.union(Box3B._box)

}
}
}
const children = object.children

for (let i = 0, l = children.length; i < l; i++) {

+ 1
- 1
src/viewer/ThreeViewer.ts Vedi File

@@ -701,7 +701,7 @@ export class ThreeViewer extends EventDispatcher<IViewerEvent, IViewerEventTypes
* Add multiple plugins to the viewer(sync).
* @param plugins - List of plugin instances or classes
*/
async addPluginsSync(plugins: (IViewerPluginSync | Class<IViewerPluginSync>)[]): Promise<void> {
addPluginsSync(plugins: (IViewerPluginSync | Class<IViewerPluginSync>)[]): void {
for (const p of plugins) this.addPluginSync(p)
}


Loading…
Annulla
Salva