瀏覽代碼

type fix

master
Palash Bansal 11 月之前
父節點
當前提交
8100d39375
No account linked to committer's email address
共有 3 個文件被更改,包括 11 次插入9 次删除
  1. 4
    4
      examples/model-viewer/script.ts
  2. 3
    1
      examples/tweakpane-editor/ThreeEditor.ts
  3. 4
    4
      examples/tweakpane-editor/script.ts

+ 4
- 4
examples/model-viewer/script.ts 查看文件

import {BloomPlugin, DepthOfFieldPlugin, SSContactShadowsPlugin, SSReflectionPlugin, TemporalAAPlugin, VelocityBufferPlugin, SSGIPlugin, AnisotropyPlugin} from '@threepipe/webgi-plugins' import {BloomPlugin, DepthOfFieldPlugin, SSContactShadowsPlugin, SSReflectionPlugin, TemporalAAPlugin, VelocityBufferPlugin, SSGIPlugin, AnisotropyPlugin} from '@threepipe/webgi-plugins'


function checkQuery(key: string, def = true) { function checkQuery(key: string, def = true) {
return !['false', 'no', 'f'].includes(getUrlQueryParam(key, def ? 'yes' : 'no').toLowerCase())
return !['false', 'no', 'f'].includes(getUrlQueryParam(key, def ? 'yes' : 'no')!.toLowerCase())
} }


async function init() { async function init() {
}, },
// set it to true if you only have opaque objects in the scene to get better performance. // set it to true if you only have opaque objects in the scene to get better performance.
zPrepass: checkQuery('depthPrepass', checkQuery('zPrepass', false)), zPrepass: checkQuery('depthPrepass', checkQuery('zPrepass', false)),
modelRootScale: parseFloat(getUrlQueryParam('modelRootScale', '1')),
modelRootScale: parseFloat(getUrlQueryParam('modelRootScale', '1')!),
dropzone: { // this can also be set to true and configured by getting a reference to the DropzonePlugin dropzone: { // this can also be set to true and configured by getting a reference to the DropzonePlugin
// allowedExtensions: ['gltf', 'glb', 'hdr', 'bin', 'png', 'jpeg', 'webp', 'jpg', 'exr', 'fbx', 'obj'], // only allow these file types. If undefined, all files are allowed. // allowedExtensions: ['gltf', 'glb', 'hdr', 'bin', 'png', 'jpeg', 'webp', 'jpg', 'exr', 'fbx', 'obj'], // only allow these file types. If undefined, all files are allowed.
addOptions: { addOptions: {
autoSetBackground: true, // when any image is dropped autoSetBackground: true, // when any image is dropped
autoScale: checkQuery('autoScale', true), // auto scale according to radius autoScale: checkQuery('autoScale', true), // auto scale according to radius
autoCenter: checkQuery('autoCenter', true), // auto center the object autoCenter: checkQuery('autoCenter', true), // auto center the object
autoScaleRadius: parseFloat(getUrlQueryParam('autoScaleRadius', '2')),
autoScaleRadius: parseFloat(getUrlQueryParam('autoScaleRadius', '2')!),
// license: 'Imported from dropzone', // Any license to set on imported objects // license: 'Imported from dropzone', // Any license to set on imported objects
importConfig: true, // import config from file importConfig: true, // import config from file
}, },


const model = getUrlQueryParam('m') || getUrlQueryParam('model') const model = getUrlQueryParam('m') || getUrlQueryParam('model')
if (model) { if (model) {
const ext = getUrlQueryParam('ext') || getUrlQueryParam('model-extension')
const ext = getUrlQueryParam('ext') || getUrlQueryParam('model-extension') || undefined
const loader = viewer.getPlugin(DropzonePlugin) ?? viewer const loader = viewer.getPlugin(DropzonePlugin) ?? viewer
const obj = await loader.load(model, {fileExtension: ext}) const obj = await loader.load(model, {fileExtension: ext})
console.log(obj) console.log(obj)

+ 3
- 1
examples/tweakpane-editor/ThreeEditor.ts 查看文件

KTX2LoadPlugin, KTXLoadPlugin, PLYLoadPlugin, Rhino3dmLoadPlugin, STLLoadPlugin, USDZLoadPlugin, KTX2LoadPlugin, KTXLoadPlugin, PLYLoadPlugin, Rhino3dmLoadPlugin, STLLoadPlugin, USDZLoadPlugin,
BlendLoadPlugin, BlendLoadPlugin,
HierarchyUiPlugin, HierarchyUiPlugin,
GeometryGeneratorPlugin, new Object3DWidgetsPlugin(false), Object3DGeneratorPlugin,
new Object3DWidgetsPlugin(false),
Object3DGeneratorPlugin,
GeometryGeneratorPlugin,
GaussianSplattingPlugin, GaussianSplattingPlugin,
// BaseGroundPlugin, // BaseGroundPlugin,
ContactShadowGroundPlugin, ContactShadowGroundPlugin,

+ 4
- 4
examples/tweakpane-editor/script.ts 查看文件

}, },
// set it to true if you only have opaque objects in the scene to get better performance. // set it to true if you only have opaque objects in the scene to get better performance.
zPrepass: checkQuery('depthPrepass', checkQuery('zPrepass', false)), zPrepass: checkQuery('depthPrepass', checkQuery('zPrepass', false)),
modelRootScale: parseFloat(getUrlQueryParam('modelRootScale', '1')),
modelRootScale: parseFloat(getUrlQueryParam('modelRootScale', '1')!),
dropzone: { dropzone: {
autoImport: true, autoImport: true,
autoAdd: true, autoAdd: true,
addOptions: { addOptions: {
autoScale: checkQuery('autoScale', true), autoScale: checkQuery('autoScale', true),
autoCenter: checkQuery('autoCenter', true), autoCenter: checkQuery('autoCenter', true),
autoScaleRadius: parseFloat(getUrlQueryParam('autoScaleRadius', '2')),
autoScaleRadius: parseFloat(getUrlQueryParam('autoScaleRadius', '2')!),
clearSceneObjects: checkQuery('clearSceneObjectsOnDrop', false), // clear the scene before adding new objects on drop. clearSceneObjects: checkQuery('clearSceneObjectsOnDrop', false), // clear the scene before adding new objects on drop.
license: getUrlQueryParam('licenseText') ?? undefined, // Any license to set on imported objects license: getUrlQueryParam('licenseText') ?? undefined, // Any license to set on imported objects
}, },


const model = getUrlQueryParam('m') || getUrlQueryParam('model') const model = getUrlQueryParam('m') || getUrlQueryParam('model')
if (model) { if (model) {
const ext = getUrlQueryParam('ext') || getUrlQueryParam('model-extension')
const ext = getUrlQueryParam('ext') || getUrlQueryParam('model-extension') || undefined
const loader = viewer.getPlugin(DropzonePlugin) ?? viewer const loader = viewer.getPlugin(DropzonePlugin) ?? viewer
const obj = await loader.load(model, {fileExtension: ext}) const obj = await loader.load(model, {fileExtension: ext})
console.log(obj) console.log(obj)
init().finally(_testFinish) init().finally(_testFinish)


function checkQuery(key: string, def = true) { function checkQuery(key: string, def = true) {
return !['false', 'no', 'f', '0'].includes(getUrlQueryParam(key, def ? 'yes' : 'no').toLowerCase())
return !['false', 'no', 'f', '0'].includes(getUrlQueryParam(key, def ? 'yes' : 'no')!.toLowerCase())
} }

Loading…
取消
儲存