Bläddra i källkod

Version bump, add prompt button for url in TilesRendererPlugin, update 3d tiles examples to use controls.

master
Palash Bansal 1 år sedan
förälder
incheckning
1e9709f493
Inget konto är kopplat till bidragsgivarens mejladress

+ 22
- 11
examples/3d-tiles-renderer/script.ts Visa fil

import {_testFinish, LoadingScreenPlugin, ThreeViewer} from 'threepipe'
import {TilesRendererPlugin} from '@threepipe/plugin-3d-tiles-renderer'
import {_testFinish, _testStart, LoadingScreenPlugin, PickingPlugin, ThreeViewer} from 'threepipe'
import {EnvironmentControls2, EnvironmentControlsPlugin, TilesRendererPlugin} from '@threepipe/plugin-3d-tiles-renderer'
import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane'


async function init() { async function init() {


autoSetBackground: true, autoSetBackground: true,
}, },
}, },
plugins: [LoadingScreenPlugin, EnvironmentControlsPlugin, PickingPlugin],
}) })


viewer.scene.mainCamera.position.set(3, 3, 4)
// viewer.scene.mainCamera.position.set(300, 300, 300)
viewer.scene.mainCamera.controlsMode = 'environment'

viewer.scene.mainCamera.position.set(150, 150, 150)
viewer.scene.mainCamera.lookAt(0, 0, 0)
// viewer.scene.mainCamera.autoNearFar = false // viewer.scene.mainCamera.autoNearFar = false
// viewer.scene.mainCamera.minNearPlane = 1 // viewer.scene.mainCamera.minNearPlane = 1
// viewer.scene.mainCamera.maxFarPlane = 1000 // viewer.scene.mainCamera.maxFarPlane = 1000


const tiles = viewer.addPluginSync(TilesRendererPlugin) const tiles = viewer.addPluginSync(TilesRendererPlugin)


viewer.addPluginSync(LoadingScreenPlugin)

// await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr', {
// setBackground: true,
// })

await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr')
const result = await tiles.load('https://raw.githubusercontent.com/NASA-AMMOS/3DTilesRendererJS/c7a9a7f7607e8759d16c26fb83815ad1cd1fd865/example/data/tileset.json', { const result = await tiles.load('https://raw.githubusercontent.com/NASA-AMMOS/3DTilesRendererJS/c7a9a7f7607e8759d16c26fb83815ad1cd1fd865/example/data/tileset.json', {
autoCenter: true, autoCenter: true,
autoScale: true, autoScale: true,
// autoScaleRadius: 100,
autoScaleRadius: 100,
tiles: {
// TilesFadePlugin: false,
},
}) })
console.log(result) console.log(result)


// optional
const controls = viewer.scene.mainCamera.controls as EnvironmentControls2
result && controls.setTilesRenderer(result.tilesRenderer)

const ui = viewer.addPluginSync(TweakpaneUiPlugin)
ui.appendChild(controls.uiConfig)
ui.setupPluginUi(PickingPlugin)

} }


_testStart()
init().finally(_testFinish) init().finally(_testFinish)

+ 13
- 6
examples/dzi-load/index.html Visa fil

overflow: hidden; overflow: hidden;
} }
</style> </style>
<script type="module" src="../examples-utils/global-loading.mjs"></script>
<script type="module" src="../examples-utils/simple-code-preview.mjs"></script> <script type="module" src="../examples-utils/simple-code-preview.mjs"></script>
<script id="example-script" type="module" lang="ts"> <script id="example-script" type="module" lang="ts">
import {_testFinish, LoadingScreenPlugin, ThreeViewer, SSAAPlugin} from 'threepipe'
import {DeepZoomImageLoadPlugin} from '@threepipe/plugin-3d-tiles-renderer'
import {_testFinish, _testStart, LoadingScreenPlugin, ThreeViewer, SSAAPlugin} from 'threepipe'
import {DeepZoomImageLoadPlugin, EnvironmentControlsPlugin} from '@threepipe/plugin-3d-tiles-renderer'


const viewer = new ThreeViewer({canvas: document.getElementById('mcanvas'), msaa: true, renderScale: window.devicePixelRatio, tonemap: false})
viewer.addPluginsSync([DeepZoomImageLoadPlugin, LoadingScreenPlugin, SSAAPlugin])
// todo why is camera change required here to start rendering?
const viewer = new ThreeViewer({canvas: document.getElementById('mcanvas'),
msaa: true, renderScale: window.devicePixelRatio,
tonemap: false})
viewer.addPluginsSync([EnvironmentControlsPlugin, DeepZoomImageLoadPlugin, LoadingScreenPlugin, SSAAPlugin])


async function init() { async function init() {


viewer.scene.mainCamera.position.set(0,0, 20) viewer.scene.mainCamera.position.set(0,0, 20)
viewer.scene.mainCamera.lookAt(0,0, 0)
viewer.scene.mainCamera.minNearPlane = 0.1 viewer.scene.mainCamera.minNearPlane = 0.1
viewer.scene.mainCamera.setDirty() viewer.scene.mainCamera.setDirty()
viewer.scene.mainCamera.controlsMode = 'environment'
viewer.scene.mainCamera.controls.minDistance = 0.3
viewer.scene.mainCamera.controls.maxDistance = 30
viewer.scene.mainCamera.controls.maxZoom = 30


// https://github.com/CesiumGS/3d-tiles-samples // https://github.com/CesiumGS/3d-tiles-samples
// from https://github.com/NASA-AMMOS/3DTilesRendererJS/blob/master/example/data/root.b3dm // from https://github.com/NASA-AMMOS/3DTilesRendererJS/blob/master/example/data/root.b3dm
console.log(result) console.log(result)
} }


_testStart()
init().finally(_testFinish) init().finally(_testFinish)
</script> </script>
</head> </head>

+ 2
- 1
examples/ogc-tiles-google-maps-3d/script.ts Visa fil

import {_testFinish, LoadingScreenPlugin, MathUtils, OrbitControls3, ThreeViewer} from 'threepipe'
import {_testFinish, _testStart, LoadingScreenPlugin, MathUtils, OrbitControls3, ThreeViewer} from 'threepipe'
import {TilesRendererPlugin, UnloadTilesPlugin, TileCompressionPlugin} from '@threepipe/plugin-3d-tiles-renderer' import {TilesRendererPlugin, UnloadTilesPlugin, TileCompressionPlugin} from '@threepipe/plugin-3d-tiles-renderer'
import {CESIUM_ION_API_TOKEN} from '../globals.js' import {CESIUM_ION_API_TOKEN} from '../globals.js'




} }


_testStart()
init().finally(_testFinish) init().finally(_testFinish)

+ 16
- 15
examples/ogc-tiles-google-maps/script.ts Visa fil

import {_testFinish, LoadingScreenPlugin, OrbitControls3, ThreeViewer} from 'threepipe'
import {TileCompressionPlugin, TilesRendererPlugin, UnloadTilesPlugin} from '@threepipe/plugin-3d-tiles-renderer'
import {_testFinish, _testStart, LoadingScreenPlugin, ThreeViewer} from 'threepipe'
import {
GlobeControls2,
GlobeControlsPlugin,
TileCompressionPlugin,
TilesRendererPlugin,
UnloadTilesPlugin,
} from '@threepipe/plugin-3d-tiles-renderer'
import {CESIUM_ION_API_TOKEN} from '../globals.js' import {CESIUM_ION_API_TOKEN} from '../globals.js'


async function init() { async function init() {
zPrepass: false, zPrepass: false,
rgbm: false, rgbm: false,
// modelRootScale: 0.01, // modelRootScale: 0.01,
plugins: [LoadingScreenPlugin, GlobeControlsPlugin],
}) })


viewer.scene.mainCamera.position.set(4800000, 2570000, 14720000) viewer.scene.mainCamera.position.set(4800000, 2570000, 14720000)
// viewer.scene.mainCamera.position.set(300, 300, 300) // viewer.scene.mainCamera.position.set(300, 300, 300)
viewer.scene.mainCamera.lookAt(0, 0, 0)
viewer.scene.mainCamera.autoNearFar = false viewer.scene.mainCamera.autoNearFar = false
viewer.scene.mainCamera.minNearPlane = 1
// viewer.scene.mainCamera.minNearPlane = 1
viewer.scene.mainCamera.maxFarPlane = 160000000 viewer.scene.mainCamera.maxFarPlane = 160000000
viewer.scene.mainCamera.fov = 60 viewer.scene.mainCamera.fov = 60
const controls = viewer.scene.mainCamera.controls as OrbitControls3
controls.minDistance = 6.379e6
viewer.scene.mainCamera.controlsMode = 'globe'
const controls = viewer.scene.mainCamera.controls as GlobeControls2
// controls.minDistance = 6.379e6
controls.maxDistance = 160000000 controls.maxDistance = 160000000
controls.clampMax.set(160000000, 160000000, 160000000)
// controls.minPolarAngle = 0
// controls.maxPolarAngle = 3 * Math.PI / 8
controls.enableDamping = true controls.enableDamping = true
// controls.autoRotate = true
// controls.autoRotateSpeed = 0.5
// controls.enablePan = false


const tiles = viewer.addPluginSync(TilesRendererPlugin) const tiles = viewer.addPluginSync(TilesRendererPlugin)


viewer.addPluginSync(LoadingScreenPlugin)

const result = await tiles.loadCesiumIon({ const result = await tiles.loadCesiumIon({
assetId: '2275207', assetId: '2275207',
apiToken: CESIUM_ION_API_TOKEN, apiToken: CESIUM_ION_API_TOKEN,
}, { }, {
autoCenter: false, autoCenter: false,
autoScale: false, autoScale: false,
// autoScaleRadius: 300,
tiles: { tiles: {
TilesFadePlugin: true, TilesFadePlugin: true,
plugins: [ plugins: [
if (result) { if (result) {
result.rotateX(-Math.PI / 2) result.rotateX(-Math.PI / 2)
result.tilesRenderer.errorTarget = 40 result.tilesRenderer.errorTarget = 40
controls.setTilesRenderer(result.tilesRenderer)
} }
console.log(result)


} }


_testStart()
init().finally(_testFinish) init().finally(_testFinish)

+ 7
- 3
examples/ogc-tiles-mars/script.ts Visa fil

import {_testFinish, FrameFadePlugin, LoadingScreenPlugin, SSAAPlugin, ThreeViewer} from 'threepipe'
import {TilesRendererPlugin} from '@threepipe/plugin-3d-tiles-renderer'
import {_testFinish, _testStart, FrameFadePlugin, LoadingScreenPlugin, SSAAPlugin, ThreeViewer} from 'threepipe'
import {EnvironmentControlsPlugin, TilesRendererPlugin} from '@threepipe/plugin-3d-tiles-renderer'
import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane' import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane'


async function init() { async function init() {
autoSetBackground: false, autoSetBackground: false,
}, },
}, },
plugins: [LoadingScreenPlugin, FrameFadePlugin, SSAAPlugin],
plugins: [LoadingScreenPlugin, FrameFadePlugin, SSAAPlugin, EnvironmentControlsPlugin],
}) })


viewer.scene.mainCamera.controlsMode = 'environment'
viewer.scene.mainCamera.controls!.minDistance = 0.25
viewer.scene.mainCamera.position.set(30, 30, 40) viewer.scene.mainCamera.position.set(30, 30, 40)
viewer.scene.mainCamera.lookAt(0, 0, 0)
// viewer.scene.mainCamera.position.set(300, 300, 300) // viewer.scene.mainCamera.position.set(300, 300, 300)
// viewer.scene.mainCamera.autoNearFar = false // viewer.scene.mainCamera.autoNearFar = false
// viewer.scene.mainCamera.minNearPlane = 1 // viewer.scene.mainCamera.minNearPlane = 1


} }


_testStart()
init().finally(_testFinish) init().finally(_testFinish)

+ 10
- 5
examples/slippy-map-tiles/index.html Visa fil

overflow: hidden; overflow: hidden;
} }
</style> </style>
<script type="module" src="../examples-utils/global-loading.mjs"></script>
<script type="module" src="../examples-utils/simple-code-preview.mjs"></script> <script type="module" src="../examples-utils/simple-code-preview.mjs"></script>
<script id="example-script" type="module" lang="ts"> <script id="example-script" type="module" lang="ts">
import {_testFinish, LoadingScreenPlugin, ThreeViewer, SSAAPlugin} from 'threepipe'
import {SlippyMapTilesLoadPlugin} from '@threepipe/plugin-3d-tiles-renderer'
import {_testFinish, _testStart, LoadingScreenPlugin, ThreeViewer, SSAAPlugin} from 'threepipe'
import {SlippyMapTilesLoadPlugin, EnvironmentControlsPlugin} from '@threepipe/plugin-3d-tiles-renderer'



const viewer = new ThreeViewer({ const viewer = new ThreeViewer({
canvas: document.getElementById('mcanvas'), canvas: document.getElementById('mcanvas'),
msaa: true, renderScale: window.devicePixelRatio, msaa: true, renderScale: window.devicePixelRatio,
tonemap: false, tonemap: false,
}) })
viewer.addPluginsSync([SlippyMapTilesLoadPlugin, LoadingScreenPlugin, SSAAPlugin])
viewer.addPluginsSync([EnvironmentControlsPlugin, SlippyMapTilesLoadPlugin, LoadingScreenPlugin, SSAAPlugin])


// todo once loaded small tiles, its not loading back the bigger ones on zoom out // todo once loaded small tiles, its not loading back the bigger ones on zoom out
// also getting weird behaviour sometimes // also getting weird behaviour sometimes
async function init() { async function init() {


viewer.scene.mainCamera.position.set(0,0, 20) viewer.scene.mainCamera.position.set(0,0, 20)
viewer.scene.mainCamera.lookAt(0,0, 0)
viewer.scene.mainCamera.minNearPlane = 0.1 viewer.scene.mainCamera.minNearPlane = 0.1
viewer.scene.mainCamera.setDirty() viewer.scene.mainCamera.setDirty()
viewer.scene.mainCamera.controlsMode = 'environment'
viewer.scene.mainCamera.controls.minDistance = 0.3
viewer.scene.mainCamera.controls.maxDistance = 30


// https://github.com/CesiumGS/3d-tiles-samples // https://github.com/CesiumGS/3d-tiles-samples
// from https://github.com/NASA-AMMOS/3DTilesRendererJS/blob/master/example/data/root.b3dm // from https://github.com/NASA-AMMOS/3DTilesRendererJS/blob/master/example/data/root.b3dm
}, },
} }
}) })
viewer.setDirty()
console.log(result)
// result.rotation.x = - Math.PI / 2; // result.rotation.x = - Math.PI / 2;
} }
_testStart()
init().finally(_testFinish) init().finally(_testFinish)
</script> </script>
</head> </head>

+ 2
- 2
package-lock.json Visa fil

{ {
"name": "threepipe", "name": "threepipe",
"version": "0.0.42",
"version": "0.0.43",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "threepipe", "name": "threepipe",
"version": "0.0.42",
"version": "0.0.43",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@types/three": "https://github.com/repalash/three-ts-types/releases/download/v0.157.1006/package.tgz", "@types/three": "https://github.com/repalash/three-ts-types/releases/download/v0.157.1006/package.tgz",

+ 1
- 1
package.json Visa fil

{ {
"name": "threepipe", "name": "threepipe",
"version": "0.0.42",
"version": "0.0.43",
"description": "A modern 3D viewer framework built on top of three.js, written in TypeScript, designed to make creating high-quality, modular, and extensible 3D experiences on the web simple and enjoyable.", "description": "A modern 3D viewer framework built on top of three.js, written in TypeScript, designed to make creating high-quality, modular, and extensible 3D experiences on the web simple and enjoyable.",
"main": "dist/index.js", "main": "dist/index.js",
"module": "dist/index.mjs", "module": "dist/index.mjs",

+ 7
- 1
plugins/3d-tiles-renderer/src/TilesRendererPlugin.ts Visa fil

Loader, Loader,
ImportAddOptions, ImportAddOptions,
LoadingManager, LoadingManager,
ThreeViewer, Sphere,
ThreeViewer, Sphere, uiButton,
} from 'threepipe' } from 'threepipe'
import {TilesGroup, TilesRenderer} from '3d-tiles-renderer' import {TilesGroup, TilesRenderer} from '3d-tiles-renderer'
import {gltfCesiumRTCExtension, gltfMeshFeaturesExtension, gltfStructuralMetadataExtension} from './gltf' import {gltfCesiumRTCExtension, gltfMeshFeaturesExtension, gltfStructuralMetadataExtension} from './gltf'
this.dispatchEvent({type: 'addTile', group}) this.dispatchEvent({type: 'addTile', group})
} }


@uiButton()
async promptForURL() {
const url = await this._viewer?.dialog.prompt('TilesRendererPlugin: Enter URL for the root tileset', '', true)
if (!url) return
return this.load(url)
}
} }


export class TilesRendererLoader extends Loader implements ILoader<TilesRendererGroup> { export class TilesRendererLoader extends Loader implements ILoader<TilesRendererGroup> {

+ 1
- 1
src/viewer/version.ts Visa fil

export const VERSION = '0.0.42'
export const VERSION = '0.0.43'

Laddar…
Avbryt
Spara