|
|
|
|
|
|
|
|
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) |