| } from 'threepipe' | } from 'threepipe' | ||||
| import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane' | import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane' | ||||
| // todo make tutorial for this in docs? | |||||
| async function init() { | async function init() { | ||||
| const viewer = new ThreeViewer({ | const viewer = new ThreeViewer({ |
| directionalLight.shadowNear = 0.1 | directionalLight.shadowNear = 0.1 | ||||
| directionalLight.shadowFar = 10 | directionalLight.shadowFar = 10 | ||||
| directionalLight.shadowFrustum = 4 | directionalLight.shadowFrustum = 4 | ||||
| directionalLight.userData.autoUpdateParent = false // so that viewer.setDirty is not called when we change any property. | |||||
| viewer.scene.addObject(directionalLight, {addToRoot: true}) | viewer.scene.addObject(directionalLight, {addToRoot: true}) | ||||
| // move to index 0 in parent.children, so that directionalLight always has index 0 in shader. required for material extension | // move to index 0 in parent.children, so that directionalLight always has index 0 in shader. required for material extension | ||||
| const parent = directionalLight.parent! | const parent = directionalLight.parent! | ||||
| return directionalLight | return directionalLight | ||||
| } | } | ||||
| function updateLight(viewer: ThreeViewer, directionalLight: DirectionalLight, histogram: ReturnType<typeof createHistogramFromImage>) { | function updateLight(viewer: ThreeViewer, directionalLight: DirectionalLight, histogram: ReturnType<typeof createHistogramFromImage>) { | ||||
| if (viewer.renderManager.frameCount < 1) return | if (viewer.renderManager.frameCount < 1) return | ||||
| // if (viewer.renderManager.frameCount > 2) return | // if (viewer.renderManager.frameCount > 2) return | ||||
| const i = viewer.renderManager.frameCount <= 1 ? histogram.brightestI : histogram.sampleIndex() | const i = viewer.renderManager.frameCount <= 1 ? histogram.brightestI : histogram.sampleIndex() | ||||
| histogram.indexToColor(i, directionalLight) | histogram.indexToColor(i, directionalLight) | ||||
| directionalLight.intensity = 0 // so it doesnt show in the scene | |||||
| directionalLight.intensity = 0 // so it doesnt show in the scene. Note that setDirty is disabled for this light (autoUpdateParent) | |||||
| histogram.indexToPosition(i, directionalLight.position).multiplyScalar(0.5 + size).add(center) | histogram.indexToPosition(i, directionalLight.position).multiplyScalar(0.5 + size).add(center) | ||||
| directionalLight.lookAt(center) | directionalLight.lookAt(center) | ||||
| directionalLight.shadow.camera.near = Math.max(size / 100, 0.1) | directionalLight.shadow.camera.near = Math.max(size / 100, 0.1) |
| ViewerUiConfigPlugin, | ViewerUiConfigPlugin, | ||||
| VignettePlugin, | VignettePlugin, | ||||
| VirtualCamerasPlugin, | VirtualCamerasPlugin, | ||||
| HemisphereLight, | |||||
| } from 'threepipe' | } from 'threepipe' | ||||
| import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane' | import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane' | ||||
| import {HierarchyUiPlugin, TweakpaneEditorPlugin} from '@threepipe/plugin-tweakpane-editor' | import {HierarchyUiPlugin, TweakpaneEditorPlugin} from '@threepipe/plugin-tweakpane-editor' |
| { | { | ||||
| "name": "threepipe", | "name": "threepipe", | ||||
| "version": "0.0.39", | |||||
| "version": "0.0.40", | |||||
| "lockfileVersion": 3, | "lockfileVersion": 3, | ||||
| "requires": true, | "requires": true, | ||||
| "packages": { | "packages": { | ||||
| "": { | "": { | ||||
| "name": "threepipe", | "name": "threepipe", | ||||
| "version": "0.0.39", | |||||
| "version": "0.0.40", | |||||
| "license": "Apache-2.0", | "license": "Apache-2.0", | ||||
| "dependencies": { | "dependencies": { | ||||
| "@types/three": "https://github.com/repalash/three-ts-types/releases/download/v0.157.1004/package.tgz", | |||||
| "@types/three": "https://github.com/repalash/three-ts-types/releases/download/v0.157.1005/package.tgz", | |||||
| "@types/webxr": "^0.5.1", | "@types/webxr": "^0.5.1", | ||||
| "@types/wicg-file-system-access": "^2020.9.5", | "@types/wicg-file-system-access": "^2020.9.5", | ||||
| "popmotion": "^11.0.5", | "popmotion": "^11.0.5", | ||||
| "rimraf": "^5.0.1", | "rimraf": "^5.0.1", | ||||
| "rollup-plugin-glsl": "^1.3.0", | "rollup-plugin-glsl": "^1.3.0", | ||||
| "rollup-plugin-license": "^3.0.1", | "rollup-plugin-license": "^3.0.1", | ||||
| "three": "https://github.com/repalash/three.js-modded/releases/download/v0.157.1004/package.tgz", | |||||
| "three": "https://github.com/repalash/three.js-modded/releases/download/v0.157.1007/package.tgz", | |||||
| "tslib": "^2.5.0", | "tslib": "^2.5.0", | ||||
| "typedoc": "^0.27.5", | "typedoc": "^0.27.5", | ||||
| "typescript": "5.7.2", | "typescript": "5.7.2", | ||||
| "win-node-env": "^0.6.1" | "win-node-env": "^0.6.1" | ||||
| }, | }, | ||||
| "peerDependencies": { | "peerDependencies": { | ||||
| "three": "https://github.com/repalash/three.js-modded/releases/download/v0.157.1004/package.tgz" | |||||
| "three": "https://github.com/repalash/three.js-modded/releases/download/v0.157.1007/package.tgz" | |||||
| }, | }, | ||||
| "peerDependenciesMeta": { | "peerDependenciesMeta": { | ||||
| "three": { | "three": { | ||||
| "license": "MIT" | "license": "MIT" | ||||
| }, | }, | ||||
| "node_modules/@types/three": { | "node_modules/@types/three": { | ||||
| "version": "0.157.1004", | |||||
| "resolved": "https://github.com/repalash/three-ts-types/releases/download/v0.157.1004/package.tgz", | |||||
| "integrity": "sha512-J5sdEce4YMYU7uYsL0b+St12VNpaQIDIrmzaiMGl/tunMtzCJBCpVFwBln7vewtCws6MopHGw2H0huAQIeEBxQ==", | |||||
| "version": "0.157.1005", | |||||
| "resolved": "https://github.com/repalash/three-ts-types/releases/download/v0.157.1005/package.tgz", | |||||
| "integrity": "sha512-Qb6XlwUyDAoNUi9IxS5lYmkShRsVFCAsG4KAXTPlmi6G2V/GIzmvXZ5Ut2SV1L+7nCEFwtvENkzP3/MVQ9cWUQ==", | |||||
| "dependencies": { | "dependencies": { | ||||
| "fflate": "~0.6.10", | "fflate": "~0.6.10", | ||||
| "meshoptimizer": "~0.18.1" | "meshoptimizer": "~0.18.1" | ||||
| "license": "MIT" | "license": "MIT" | ||||
| }, | }, | ||||
| "node_modules/three": { | "node_modules/three": { | ||||
| "version": "0.157.1004", | |||||
| "resolved": "https://github.com/repalash/three.js-modded/releases/download/v0.157.1004/package.tgz", | |||||
| "integrity": "sha512-91lAxpFKhjnxV20rVODh2QehyEAgKlMghL0wiZLwxYKxueLJ/6ZH74yEEsMWHV+Jgf1I598OGzD6Xzecs8Epwg==", | |||||
| "version": "0.157.1007", | |||||
| "resolved": "https://github.com/repalash/three.js-modded/releases/download/v0.157.1007/package.tgz", | |||||
| "integrity": "sha512-VjnxBF9JRjkFrqnHcrpa6VuOHSPyQzzLSYBUrPq0qJZmHhTVo4ns6MmZ8TA0v0kCu9pPNILDH9ZBY5d84v4UPA==", | |||||
| "dev": true, | "dev": true, | ||||
| "license": "MIT" | "license": "MIT" | ||||
| }, | }, |
| { | { | ||||
| "name": "threepipe", | "name": "threepipe", | ||||
| "version": "0.0.40-dev", | |||||
| "version": "0.0.40", | |||||
| "description": "A 3D viewer framework built on top of three.js in TypeScript with a focus on quality rendering, modularity and extensibility.", | "description": "A 3D viewer framework built on top of three.js in TypeScript with a focus on quality rendering, modularity and extensibility.", | ||||
| "main": "dist/index.js", | "main": "dist/index.js", | ||||
| "module": "dist/index.mjs", | "module": "dist/index.mjs", |
| { | { | ||||
| "name": "@threepipe/plugin-blend-importer", | "name": "@threepipe/plugin-blend-importer", | ||||
| "version": "0.0.3", | |||||
| "version": "0.0.4", | |||||
| "lockfileVersion": 3, | "lockfileVersion": 3, | ||||
| "requires": true, | "requires": true, | ||||
| "packages": { | "packages": { | ||||
| "": { | "": { | ||||
| "name": "@threepipe/plugin-blend-importer", | "name": "@threepipe/plugin-blend-importer", | ||||
| "version": "0.0.3", | |||||
| "version": "0.0.4", | |||||
| "license": "Apache-2.0", | "license": "Apache-2.0", | ||||
| "dependencies": { | "dependencies": { | ||||
| "threepipe": "file:./../../src/" | "threepipe": "file:./../../src/" |
| { | { | ||||
| "name": "@threepipe/plugin-blueprintjs", | "name": "@threepipe/plugin-blueprintjs", | ||||
| "version": "0.3.2", | |||||
| "version": "0.3.3", | |||||
| "lockfileVersion": 3, | "lockfileVersion": 3, | ||||
| "requires": true, | "requires": true, | ||||
| "packages": { | "packages": { | ||||
| "": { | "": { | ||||
| "name": "@threepipe/plugin-blueprintjs", | "name": "@threepipe/plugin-blueprintjs", | ||||
| "version": "0.3.2", | |||||
| "version": "0.3.3", | |||||
| "license": "Apache-2.0", | "license": "Apache-2.0", | ||||
| "dependencies": { | "dependencies": { | ||||
| "threepipe": "file:./../../src/" | "threepipe": "file:./../../src/" |
| { | { | ||||
| "name": "@threepipe/plugin-configurator", | "name": "@threepipe/plugin-configurator", | ||||
| "version": "0.1.2", | |||||
| "version": "0.1.3", | |||||
| "lockfileVersion": 3, | "lockfileVersion": 3, | ||||
| "requires": true, | "requires": true, | ||||
| "packages": { | "packages": { | ||||
| "": { | "": { | ||||
| "name": "@threepipe/plugin-configurator", | "name": "@threepipe/plugin-configurator", | ||||
| "version": "0.1.2", | |||||
| "version": "0.1.3", | |||||
| "license": "Apache-2.0", | "license": "Apache-2.0", | ||||
| "dependencies": { | "dependencies": { | ||||
| "threepipe": "file:./../../src/", | "threepipe": "file:./../../src/", |
| { | { | ||||
| "name": "@threepipe/plugins-extra-importers", | "name": "@threepipe/plugins-extra-importers", | ||||
| "version": "0.2.2", | |||||
| "version": "0.2.3", | |||||
| "lockfileVersion": 3, | "lockfileVersion": 3, | ||||
| "requires": true, | "requires": true, | ||||
| "packages": { | "packages": { | ||||
| "": { | "": { | ||||
| "name": "@threepipe/plugins-extra-importers", | "name": "@threepipe/plugins-extra-importers", | ||||
| "version": "0.2.2", | |||||
| "version": "0.2.3", | |||||
| "license": "Apache-2.0", | "license": "Apache-2.0", | ||||
| "dependencies": { | "dependencies": { | ||||
| "threepipe": "file:./../../src/" | "threepipe": "file:./../../src/" |
| { | { | ||||
| "name": "@threepipe/plugin-gltf-transform", | "name": "@threepipe/plugin-gltf-transform", | ||||
| "version": "0.1.2", | |||||
| "version": "0.1.3", | |||||
| "lockfileVersion": 3, | "lockfileVersion": 3, | ||||
| "requires": true, | "requires": true, | ||||
| "packages": { | "packages": { | ||||
| "": { | "": { | ||||
| "name": "@threepipe/plugin-gltf-transform", | "name": "@threepipe/plugin-gltf-transform", | ||||
| "version": "0.1.2", | |||||
| "version": "0.1.3", | |||||
| "license": "Apache-2.0", | "license": "Apache-2.0", | ||||
| "dependencies": { | "dependencies": { | ||||
| "threepipe": "file:./../../src/" | "threepipe": "file:./../../src/" |
| { | { | ||||
| "name": "@threepipe/plugin-network", | "name": "@threepipe/plugin-network", | ||||
| "version": "0.1.1", | |||||
| "version": "0.1.2", | |||||
| "lockfileVersion": 3, | "lockfileVersion": 3, | ||||
| "requires": true, | "requires": true, | ||||
| "packages": { | "packages": { | ||||
| "": { | "": { | ||||
| "name": "@threepipe/plugin-network", | "name": "@threepipe/plugin-network", | ||||
| "version": "0.1.1", | |||||
| "version": "0.1.2", | |||||
| "license": "Apache-2.0", | "license": "Apache-2.0", | ||||
| "dependencies": { | "dependencies": { | ||||
| "aws4fetch": "^1.0.18", | "aws4fetch": "^1.0.18", |
| { | { | ||||
| "name": "@threepipe/plugin-svg-renderer", | "name": "@threepipe/plugin-svg-renderer", | ||||
| "version": "0.2.2", | |||||
| "version": "0.2.3", | |||||
| "lockfileVersion": 3, | "lockfileVersion": 3, | ||||
| "requires": true, | "requires": true, | ||||
| "packages": { | "packages": { | ||||
| "": { | "": { | ||||
| "name": "@threepipe/plugin-svg-renderer", | "name": "@threepipe/plugin-svg-renderer", | ||||
| "version": "0.2.2", | |||||
| "version": "0.2.3", | |||||
| "license": "GPLV3", | "license": "GPLV3", | ||||
| "dependencies": { | "dependencies": { | ||||
| "threepipe": "file:./../../src/" | "threepipe": "file:./../../src/" | ||||
| } | } | ||||
| }, | }, | ||||
| "../../node_modules/three": { | "../../node_modules/three": { | ||||
| "version": "0.157.1004", | |||||
| "version": "0.157.1007", | |||||
| "dev": true, | "dev": true, | ||||
| "license": "MIT", | "license": "MIT", | ||||
| "devDependencies": { | "devDependencies": { |
| { | { | ||||
| "name": "@threepipe/plugin-tweakpane", | "name": "@threepipe/plugin-tweakpane", | ||||
| "version": "0.5.3", | |||||
| "version": "0.5.4", | |||||
| "lockfileVersion": 3, | "lockfileVersion": 3, | ||||
| "requires": true, | "requires": true, | ||||
| "packages": { | "packages": { | ||||
| "": { | "": { | ||||
| "name": "@threepipe/plugin-tweakpane", | "name": "@threepipe/plugin-tweakpane", | ||||
| "version": "0.5.3", | |||||
| "version": "0.5.4", | |||||
| "license": "Apache-2.0", | "license": "Apache-2.0", | ||||
| "dependencies": { | "dependencies": { | ||||
| "threepipe": "file:./../../src/" | "threepipe": "file:./../../src/" |
| */ | */ | ||||
| userSelectable?: boolean | userSelectable?: boolean | ||||
| /** | |||||
| * Disables `bubbleToParent` in setDirty calls on the object. As an effect scene, viewer are not updated on property change. See progressive-hdr-shadows-exp or any baker. | |||||
| */ | |||||
| autoUpdateParent?: boolean | |||||
| /** | /** | ||||
| * For Physics plugins | * For Physics plugins | ||||
| */ | */ |
| /** | /** | ||||
| * Deserializes the material from JSON. | * Deserializes the material from JSON. | ||||
| * Textures should be loaded and in meta.textures before calling this method. | * Textures should be loaded and in meta.textures before calling this method. | ||||
| * todo - needs to be tested | |||||
| * @param data | * @param data | ||||
| * @param meta | * @param meta | ||||
| * @param _internal | * @param _internal | ||||
| ThreeSerialization.Deserialize(data, this, meta, true) | ThreeSerialization.Deserialize(data, this, meta, true) | ||||
| return this.setValues(data) | return this.setValues(data) | ||||
| } | } | ||||
| // this will deserialize the material from the outside because we need access to the viewer to load textures | |||||
| // todo check if the material is in scene? if not, show an error/warning? | |||||
| this.dispatchEvent({type: 'beforeDeserialize', data, meta, bubbleToObject: true, bubbleToParent: true}) | this.dispatchEvent({type: 'beforeDeserialize', data, meta, bubbleToObject: true, bubbleToParent: true}) | ||||
| return this | return this | ||||
| } | } |
| if (typeof options === 'string') { // just incase called by decorators | if (typeof options === 'string') { // just incase called by decorators | ||||
| options = {change: options} | options = {change: options} | ||||
| } | } | ||||
| this.dispatchEvent({bubbleToParent: true, ...options, type: 'objectUpdate', object: this, args}) // this sets sceneUpdate in root scene | |||||
| this.dispatchEvent({bubbleToParent: this.userData?.autoUpdateParent ?? true, ...options, type: 'objectUpdate', object: this, args}) // this sets sceneUpdate in root scene | |||||
| if (options?.refreshUi !== false && options?.last !== false) this.refreshUi?.() | if (options?.refreshUi !== false && options?.last !== false) this.refreshUi?.() | ||||
| // console.log('object update') | // console.log('object update') | ||||
| }, | }, |
| export const VERSION = '0.0.39' | |||||
| export const VERSION = '0.0.40' |