Giter VIP home page Giter VIP logo

node-three-gltf's People

Contributors

brakebein avatar nfss10 avatar sollidy avatar upisfree avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

node-three-gltf's Issues

TypeError: Cannot read properties of undefined (reading 'extensions')

Hi there. I tried to replicate your example. My draco-compressed gltf file was not processed and console.logs were not generated. Was there something missing?

Error log:

TypeError: Cannot read properties of undefined (reading 'extensions')
    at GLTFTextureBasisUExtension.loadTexture (file:///C:/Users/Node-Three-GLTF-Test/node_modules/node-three-gltf/build/index.js:792:25)
    at file:///C:/Users/Node-Three-GLTF-Test/node_modules/node-three-gltf/build/index.js:1634:80
    at GLTFParser._invokeOne (file:///C:/Users/Node-Three-GLTF-Test/node_modules/node-three-gltf/build/index.js:1590:28)
    at GLTFParser.getDependency (file:///C:/Users/Node-Three-GLTF-Test/node_modules/node-three-gltf/build/index.js:1634:39)
    at GLTFParser.assignTexture (file:///C:/Users/Node-Three-GLTF-Test/node_modules/node-three-gltf/build/index.js:1825:21)
    at GLTFMaterialsSpecularExtension.extendMaterialParams (file:///C:/Users/Node-Three-GLTF-Test/node_modules/node-three-gltf/build/index.js:776:33)
    at file:///C:/Users/Node-Three-GLTF-Test/node_modules/node-three-gltf/build/index.js:1948:56
    at GLTFParser._invokeAll (file:///C:/Users/Node-Three-GLTF-Test/node_modules/node-three-gltf/build/index.js:1601:28)
    at GLTFParser.loadMaterial (file:///C:/Users/Node-Three-GLTF-Test/node_modules/node-three-gltf/build/index.js:1947:43)
    at file:///C:/Users/Node-Three-GLTF-Test/node_modules/node-three-gltf/build/index.js:1631:81
file:///C:/Users/Node-Three-GLTF-Test/node_modules/node-three-gltf/build/index.js:792
        if (!textureDef.extensions || !textureDef.extensions[this.name]) {
                        ^

TypeError: Cannot read properties of undefined (reading 'extensions')
    at GLTFTextureBasisUExtension.loadTexture (file:///C:/Users/Node-Three-GLTF-Test/node_modules/node-three-gltf/build/index.js:792:25)
    at file:///C:/Users/Node-Three-GLTF-Test/node_modules/node-three-gltf/build/index.js:1634:80
    at GLTFParser._invokeOne (file:///C:/Users/Node-Three-GLTF-Test/node_modules/node-three-gltf/build/index.js:1590:28)
    at GLTFParser.getDependency (file:///C:/Users/Node-Three-GLTF-Test/node_modules/node-three-gltf/build/index.js:1634:39)
    at GLTFParser.assignTexture (file:///C:/Users/Node-Three-GLTF-Test/node_modules/node-three-gltf/build/index.js:1825:21)
    at GLTFMaterialsSpecularExtension.extendMaterialParams (file:///C:/Users/Node-Three-GLTF-Test/node_modules/node-three-gltf/build/index.js:776:33)
    at file:///C:/Users/Node-Three-GLTF-Test/node_modules/node-three-gltf/build/index.js:1948:56
    at GLTFParser._invokeAll (file:///C:/Users/Node-Three-GLTF-Test/node_modules/node-three-gltf/build/index.js:1601:28)
    at GLTFParser.loadMaterial (file:///C:/Users/Node-Three-GLTF-Test/node_modules/node-three-gltf/build/index.js:1947:43)
    at file:///C:/Users/Node-Three-GLTF-Test/node_modules/node-three-gltf/build/index.js:1631:81

Node.js v18.14.0

index.js:

// Import Express, set up the homepage route, and use only ES modules
import express from 'express';
import loadModel from './src/js/loadModel.js';

const app = express();
const port = 3000;

app.get('/', async (req, res) => {
    const fileData = await loadModel();
    console.log('What is this?', fileData);
}
);

app.listen(port, () => {
    console.log(`Example app listening at http://localhost:${port}`);
}
);

/js/loadModel.js:

import { DRACOLoader, GLTFLoader, loadGltf } from 'node-three-gltf';
import fs from 'fs';

const loadModel = async () => {
    const filePath = './src/assets/dracoModel.gltf';

    if (!fs.existsSync(filePath)) {
        console.log('File not found');
        return;
    };
    
    // init GLTFLoader and pass a path to a local file or a url to a web resource
    const loader = new GLTFLoader();
    loader.setDRACOLoader(new DRACOLoader());

    loader.load(filePath, gltf => {
        console.log(gltf.scene.children);
    });

    // there is also a small utility function that instantiates GLTFLoader and DRACOLoader
    // and returns a Promise with the loaded content
    const gltf = await loadGltf(filePath);
    console.log(gltf.scene.children);
};

export default loadModel;

Buffer.buffer contains incorrect data

I found geometry.attributes data is wrong.
The reason is Buffer.buffer 's data is ArrayBuffer(8192).

f1fdab6ae68dd35f24cc4f5c67f79e5

node version: 16
"dependencies": {
"base64-js": "1.5.1",
"node-three-gltf": "1.3.0",
"three": "0.147.0"
}

Filesize

Very large data return from GLTFLoader.

The model size is just 5-6Mb .... but the GLTFLoader loaded data is 324Mb.

Screen Shot 2022-10-05 at 11 18 49

Screen Shot 2022-10-05 at 11 19 09

Upgrade sharp version

Please, can you upgrade version of sharp to latest (i tested v.0.33.3, work perfect), cause when i use your module inside node-worker, i got this error:
Screenshot from 2024-04-17 23-11-48

GLTFExporter support

This loader works very well, I think the Three.GLTFExporter for node should be supported as well;
Especially when exporting GLTF models with images

Need help for GLTFLoader scene

Hi,

Thank you for sharing a great library.

I am new to ThreeJS. And I was having trouble using GLTFLoader.

I used useGLTF (@react-three/drei). But it seems that the useGLTF scene and the GLTFLoader scene are different.

I can't use GLTFLoader's scene to render with <primitive object={model.scene} />.

Where did I go wrong? Or is it wrong to use primitive in this case?

Thank you so much.

This is GLTFLoader scene:
Screen Shot 2022-10-01 at 23 52 17

And this is useGLTF scene:
Screen Shot 2022-10-01 at 23 52 32

TextureLoader return different data between node-three-gltf and threejs on transparent pixel

I load a png image with transparent pixel
threejs is 0,0,0,0
image

// three_r148/src/extras/ImageUtils.js after line 49
const context = canvas.getContext('2d')
const imageData = context.getImageData(0, 0, canvas.width, canvas.height);
console.log(imageData)
for (let i = 0; i < imageData.width * imageData.height; i++) {
	const r = imageData.data[i * 4]
	const g = imageData.data[i * 4 + 1]
	const b = imageData.data[i * 4 + 2]
	const a = imageData.data[i * 4 + 3]
	console.log(i, '--', r, g, b, a)
}

node-three-gltf is 255,255,255,0
image

const textureLoader = new TextureLoader()
const metalnessMap = await textureLoader.loadAsync('./assets/textures/metalness.png')
// metalnessMap.encoding = sRGBEncoding

if (metalnessMap?.source?.data) {
    const imageData = metalnessMap.source.data
    for (let i = 0; i < imageData.width * imageData.height; i++) {
        const r = imageData.data[i * 4]
        const g = imageData.data[i * 4 + 1]
        const b = imageData.data[i * 4 + 2]
        const a = imageData.data[i * 4 + 3]
        console.log(i, '--', r, g, b, a)
    }
}

image.zip

setMeshoptDecoder must be called before loading compressed files

import {
  DRACOLoader,
  GLTFLoader,
  loadGltf as loadAsync,
} from "node-three-gltf";
import { MeshoptDecoder } from "three-stdlib";

export const loadGltf = async (url: string) => {
  const gltf = new GLTFLoader();
  const draco = new DRACOLoader();
  gltf.setDRACOLoader(draco);
  gltf.setMeshoptDecoder(MeshoptDecoder);

  return await loadAsync(url);
};

results in

Error: THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files

How can I load compressed gltfs?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.