Selaa lähdekoodia

Minor fixes and upgrades

master
Palash Bansal 2 vuotta sitten
vanhempi
commit
f4106eb845
No account linked to committer's email address

+ 1
- 0
.github/workflows/deploy-pages.yml Näytä tiedosto

with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
cache: 'npm' 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 ci # this will also run `npm run prepare` which will build
- run: npm run docs - run: npm run docs
- run: mkdir _site - run: mkdir _site

+ 34
- 44
package-lock.json Näytä tiedosto

{ {
"name": "threepipe", "name": "threepipe",
"version": "0.0.14",
"version": "0.0.13",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "threepipe", "name": "threepipe",
"version": "0.0.14",
"version": "0.0.13",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@types/three": "https://github.com/repalash/three-ts-types/releases/download/v0.152.1014/package.tgz", "@types/three": "https://github.com/repalash/three-ts-types/releases/download/v0.152.1014/package.tgz",
"@rollup/plugin-commonjs": "^25.0.0", "@rollup/plugin-commonjs": "^25.0.0",
"@rollup/plugin-json": "^6.0.0", "@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.2", "@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-terser": "^0.4.3", "@rollup/plugin-terser": "^0.4.3",
"@rollup/plugin-typescript": "^11.1.1", "@rollup/plugin-typescript": "^11.1.1",
"@types/stats.js": "^0.17.0", "@types/stats.js": "^0.17.0",
"rollup-plugin-glsl": "^1.3.0", "rollup-plugin-glsl": "^1.3.0",
"rollup-plugin-license": "^3.0.1", "rollup-plugin-license": "^3.0.1",
"rollup-plugin-postcss": "^4.0.2", "rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-replace": "^2.2.0",
"stats.js": "^0.17.0", "stats.js": "^0.17.0",
"three": "https://github.com/repalash/three.js-modded/releases/download/v0.152.2012/package.tgz", "three": "https://github.com/repalash/three.js-modded/releases/download/v0.152.2012/package.tgz",
"tslib": "^2.5.0", "tslib": "^2.5.0",
} }
} }
}, },
"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": { "node_modules/@rollup/plugin-terser": {
"version": "0.4.3", "version": "0.4.3",
"resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.4.3.tgz", "resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.4.3.tgz",
"postcss": "8.x" "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": { "node_modules/rollup-pluginutils": {
"version": "2.8.2", "version": "2.8.2",
"resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz",
"resolve": "^1.22.1" "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": { "@rollup/plugin-terser": {
"version": "0.4.3", "version": "0.4.3",
"resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.4.3.tgz", "resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.4.3.tgz",
"style-inject": "^0.3.0" "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": { "rollup-pluginutils": {
"version": "2.8.2", "version": "2.8.2",
"resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz",

+ 1
- 1
package.json Näytä tiedosto

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

+ 3
- 3
plugins/extra-importers/package.json Näytä tiedosto

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

+ 17
- 15
plugins/extra-importers/rollup.config.mjs Näytä tiedosto

import typescript from '@rollup/plugin-typescript'; import typescript from '@rollup/plugin-typescript';
import license from 'rollup-plugin-license' import license from 'rollup-plugin-license'
import packageJson from './package.json' assert {type: 'json'}; 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 postcss from 'rollup-plugin-postcss'
import replace from 'rollup-plugin-replace'
import replace from '@rollup/plugin-replace'
import terser from "@rollup/plugin-terser"; import terser from "@rollup/plugin-terser";


const __filename = fileURLToPath(import.meta.url); const __filename = fileURLToPath(import.meta.url);
isProduction && terser() 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), external: Object.keys(settings.globals),
plugins: [ plugins: [
replace({ 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({ postcss({
modules: false, modules: false,

+ 4
- 1
plugins/extra-importers/tsconfig.json Näytä tiedosto

"es2020", "es2020",
"esnext", "esnext",
"dom" "dom"
]
],
"paths": {
"three": ["threepipe"]
}
}, },
"include": [ "include": [
"src/**/*" "src/**/*"

+ 7
- 4
plugins/plugin-template-rollup/rollup.config.mjs Näytä tiedosto

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


const __filename = fileURLToPath(import.meta.url); const __filename = fileURLToPath(import.meta.url);


const settings = { const settings = {
globals: { globals: {
"three": "threepipe", // just incase someone uses three
"threepipe": "threepipe", "threepipe": "threepipe",
"@threepipe/plugin-tweakpane": "@threepipe/plugin-tweakpane" "@threepipe/plugin-tweakpane": "@threepipe/plugin-tweakpane"
}, },
external: Object.keys(settings.globals), external: Object.keys(settings.globals),
plugins: [ plugins: [
replace({ 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({ postcss({
modules: false, modules: false,

+ 8
- 5
plugins/tweakpane-editor/rollup.config.mjs Näytä tiedosto

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


const __filename = fileURLToPath(import.meta.url); const __filename = fileURLToPath(import.meta.url);


const settings = { const settings = {
globals: { globals: {
"three": "threepipe",
"threepipe": "threepipe", "threepipe": "threepipe",
"@threepipe/plugin-tweakpane": "@threepipe/plugin-tweakpane"
"@threepipe/plugin-tweakpane": "@threepipe/plugin-tweakpane" // would be used in externals
}, },
sourcemap: true sourcemap: true
} }
external: Object.keys(settings.globals), external: Object.keys(settings.globals),
plugins: [ plugins: [
replace({ 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({ postcss({
modules: false, modules: false,

+ 7
- 4
plugins/tweakpane/rollup.config.mjs Näytä tiedosto

import {fileURLToPath} from 'url'; import {fileURLToPath} from 'url';
import terser from "@rollup/plugin-terser"; import terser from "@rollup/plugin-terser";
import postcss from 'rollup-plugin-postcss' 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 __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename); const __dirname = path.dirname(__filename);


const settings = { const settings = {
globals: { globals: {
"three": "threepipe",
"threepipe": "threepipe" "threepipe": "threepipe"
}, },
sourcemap: true sourcemap: true
external: Object.keys(settings.globals), external: Object.keys(settings.globals),
plugins: [ plugins: [
replace({ 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({ postcss({
modules: false, modules: false,

+ 18
- 12
rollup.config.mjs Näytä tiedosto

import packageJson from './package.json' assert {type: 'json'}; import packageJson from './package.json' assert {type: 'json'};
import path from 'path' import path from 'path'
import {fileURLToPath} from 'url'; import {fileURLToPath} from 'url';
import terser from "@rollup/plugin-terser";
import postcss from 'rollup-plugin-postcss' import postcss from 'rollup-plugin-postcss'
import glsl from "rollup-plugin-glsl" 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 __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename); const __dirname = path.dirname(__filename);
// preserveModulesRoot: 'src', // optional but useful to create a more plain folder structure // preserveModulesRoot: 'src', // optional but useful to create a more plain folder structure
format: 'es' format: 'es'
}, },
{
file: browser,
...settings,
name: name,
format: 'umd',
plugins: [
isProduction && terser()
]
}
// {
// file: browser,
// ...settings,
// name: name,
// format: 'umd',
// plugins: [
// isProduction && terser()
// ]
// }
], ],
external: [], external: [],
plugins: [ plugins: [
replace({ 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. glsl({ // todo: minify glsl.
include: "src/**/*.glsl" include: "src/**/*.glsl"
}), }),

+ 1
- 1
src/assetmanager/AssetManager.ts Näytä tiedosto

}, ['exr'], ['image/x-exr'], false), }, ['exr'], ['image/x-exr'], false),


new Importer(FBXLoader, ['fbx'], ['model/fbx'], true), 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(OBJLoader2 as any as Class<ILoader>, ['obj'], ['model/obj'], true),
new Importer(MTLLoader2 as any as Class<ILoader>, ['mtl'], ['model/mtl'], false), new Importer(MTLLoader2 as any as Class<ILoader>, ['mtl'], ['model/mtl'], false),

+ 2
- 2
src/assetmanager/import/OBJLoader2.ts Näytä tiedosto

loader.setPath( this.path ); loader.setPath( this.path );
loader.setRequestHeader( this.requestHeader ); loader.setRequestHeader( this.requestHeader );
loader.setWithCredentials( this.withCredentials ); loader.setWithCredentials( this.withCredentials );
this.currentUrl = url;
scope.currentUrl = url;
loader.load( url, async function ( text ) { loader.load( url, async function ( text ) {


try { try {


} }


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


}, onProgress, onError ); }, onProgress, onError );



+ 33
- 15
src/three/math/Box3B.ts Näytä tiedosto

if (object.userData?.bboxVisible === false) return this if (object.userData?.bboxVisible === false) return this
if (!object.visible && ignoreInvisible) 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), // Computes the world-axis-aligned bounding box of an object (including its children),
// accounting for both the object's, and children's, world transforms // accounting for both the object's, and children's, world transforms


object.updateWorldMatrix(false, false) 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 const children = object.children


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

+ 1
- 1
src/viewer/ThreeViewer.ts Näytä tiedosto

* Add multiple plugins to the viewer(sync). * Add multiple plugins to the viewer(sync).
* @param plugins - List of plugin instances or classes * @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) for (const p of plugins) this.addPluginSync(p)
} }



Loading…
Peruuta
Tallenna