naver / egjs-view3d

Fast & customizable 3D model viewer for everyone
https://naver.github.io/egjs-view3d
MIT License
199 stars 30 forks source link

(Model preview) should support transparency #8

Closed freder closed 2 years ago

freder commented 2 years ago

three.js demo vs. this library

image image

freder commented 2 years ago

my assumption is that this is due to an old version of three.js being used here. so I tried using GLTFLoader and DRACOLoader from three.js directly:

import View3D, {
    // GLTFLoader,
    // THREE,
    SceneViewerSession,
    QuickLookSession,
    Pose,
    AutoDirectionalLight,
    OrbitControl
} from '@egjs/view3d';
import { DRACOLoader } from '../node_modules/three/examples/jsm/loaders/DRACOLoader.js';
import { GLTFLoader } from '../node_modules/three/examples/jsm/loaders/GLTFLoader.js';

const loader = new GLTFLoader();
const dracoLoader = new DRACOLoader();
dracoLoader.setDecoderPath('/draco/gltf/');
// dracoLoader.setDecoderConfig({ type: 'js' });

// [...]
freder commented 2 years ago

for a workaround (not showing a model preview at all) – what would be the recommended way to use this library without having to initialize a <canvas>?

WoodNeck commented 2 years ago

Hello @freder! Like you've suggested, I also think that cause is the old three.js version, as it didn't support KHR_materials_transmission extension of glTF.

Unfortunately, I think the only solution is updating the three.js version. If that was just a tedious job, I would love to do it but as Three's interface is quite changed it can take a while to update.

But, we're about to release a new version within a month! image I've just tested that model using the same envmap (royal_esplanade_1k), and it works fine. It can show a bit different color as I'm using LinearToneMapping here, while the Three's demo is using ACESFilmicToneMapping, but I'll make an option for this :)

WoodNeck commented 2 years ago

image

ACESFilmicToneMapping

freder commented 2 years ago

cool 👍 for now I simply built a basic model viewer in three.js directly.

[...] what would be the recommended way to use this library without having to initialize a <canvas>?

that was easy enough. in case it's useful to someone else:

import { SceneViewerSession, QuickLookSession } from '@egjs/view3d';
import { GLTFLoader } from '../node_modules/three/examples/jsm/loaders/GLTFLoader.js';

const loader = new GLTFLoader();
const sessions = [];

function addSession(session) {
    sessions.push(session);
}

async function enter() {
    for (let i = 0; i < sessions.length; i++) {
        const sess = sessions[i];
        const isAvailable = await sess.isAvailable();
        if (isAvailable) {
            return await sess.enter();
        }
    }
    throw new Error('Session not available');
}

loader.load(modelPathGltf, (model) => {
    // ...
});

// android
addSession(new SceneViewerSession({
    file: new URL(modelPathGltf, location.href).href,
    title: modelTitle,
    link: modelPathGltf,
    resizable: false,
    mode: 'ar_only'
}));

// ios
addSession(new QuickLookSession({
    file: new URL(modelPathUsdz, location.href).href,
}));
WoodNeck commented 2 years ago

@freder Hello! I've just released a preview of the next version with the tag next.

You can install it like this:

npm i @egjs/view3d@next

Check the document & demo on here:

That model is also tested :) image

freder commented 1 year ago

[...] what would be the recommended way to use this library without having to initialize a ?

currently looking into the same thing again, but with the latest version of this library...

WoodNeck commented 1 year ago

@freder Hi, what is the feature you are looking for? Is it possible to solve it with autoInit?