Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor: use more three/addons/* alias #27967

Merged
merged 2 commits into from Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions editor/js/Loader.js
Expand Up @@ -90,7 +90,7 @@ function Loader( editor ) {
const { Rhino3dmLoader } = await import( 'three/addons/loaders/3DMLoader.js' );

const loader = new Rhino3dmLoader();
loader.setLibraryPath( '../examples/jsm/libs/rhino3dm/' );
loader.setLibraryPath( 'three/addons/libs/rhino3dm/' );
loader.parse( contents, function ( object ) {

object.name = filename;
Expand Down Expand Up @@ -205,7 +205,7 @@ function Loader( editor ) {
const { DRACOLoader } = await import( 'three/addons/loaders/DRACOLoader.js' );

const loader = new DRACOLoader();
loader.setDecoderPath( '../examples/jsm/libs/draco/' );
loader.setDecoderPath( 'three/addons/libs/draco/' );
loader.parse( contents, function ( geometry ) {

let object;
Expand Down Expand Up @@ -431,7 +431,7 @@ function Loader( editor ) {
const { LDrawLoader } = await import( 'three/addons/loaders/LDrawLoader.js' );

const loader = new LDrawLoader();
loader.setPath( '../../examples/models/ldraw/officialLibrary/' );
loader.setPath( 'three/examples/models/ldraw/officialLibrary/' );
loader.parse( event.target.result, function ( group ) {

group.name = filename;
Expand Down Expand Up @@ -506,7 +506,7 @@ function Loader( editor ) {

const contents = event.target.result;

const { PCDLoader } = await import( '../../examples/jsm/loaders/PCDLoader.js' );
const { PCDLoader } = await import( 'three/addons/loaders/PCDLoader.js' );

const points = new PCDLoader().parse( contents );
points.name = filename;
Expand Down Expand Up @@ -653,7 +653,7 @@ function Loader( editor ) {

const contents = event.target.result;

const { USDZLoader } = await import( '../../examples/jsm/loaders/USDZLoader.js' );
const { USDZLoader } = await import( 'three/addons/loaders/USDZLoader.js' );

const group = new USDZLoader().parse( contents );
group.name = filename;
Expand Down Expand Up @@ -995,10 +995,10 @@ function Loader( editor ) {
const { MeshoptDecoder } = await import( 'three/addons/libs/meshopt_decoder.module.js' );

const dracoLoader = new DRACOLoader();
dracoLoader.setDecoderPath( '../examples/jsm/libs/draco/gltf/' );
dracoLoader.setDecoderPath( 'three/addons/libs/draco/gltf/' );

const ktx2Loader = new KTX2Loader();
ktx2Loader.setTranscoderPath( '../examples/jsm/libs/basis/' );
ktx2Loader.setTranscoderPath( 'three/addons/libs/basis/' );
Copy link
Collaborator

@Mugen87 Mugen87 Mar 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change does not work. If you now import a compressed glTF asset (like coffeemat.glb) or a 3DM file the import fails and you see 404 HTTP errors in the browser console.

You can only use the addons alias if your import via ES6 import syntax. If you load from a URL e.g. via fetch, you have to use the real directoy path meaning examples/jsm.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I again checked all the changes and fixed lines that do not work.
It's my bad that I only test a subset and I'll do more careful tests before my next prs. Thanks!


editor.signals.rendererDetectKTX2Support.dispatch( ktx2Loader );

Expand Down
2 changes: 1 addition & 1 deletion editor/js/Viewport.ViewHelper.js
@@ -1,6 +1,6 @@
import { UIPanel } from './libs/ui.js';

import { ViewHelper as ViewHelperBase } from '../../examples/jsm/helpers/ViewHelper.js';
import { ViewHelper as ViewHelperBase } from 'three/addons/helpers/ViewHelper.js';

class ViewHelper extends ViewHelperBase {

Expand Down