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

从 https://threejs.org/editor/ 导出的json,不能使用 #194

Closed
xinde opened this issue Jul 8, 2020 · 4 comments
Closed

从 https://threejs.org/editor/ 导出的json,不能使用 #194

xinde opened this issue Jul 8, 2020 · 4 comments

Comments

@xinde
Copy link

xinde commented Jul 8, 2020

https://spritejs.org/#/zh-cn/ext3d/index?id=%e7%bb%98%e5%88%b6%e6%a8%a1%e5%9e%8b
SpriteJSNext的3D扩展支持ThreeJS的json数据模型,因此只需要将模型以model参数传给Mesh3D对象即可。

请问如何能快捷准确的导入3d模型呢,比如从obj转json,或者还是有其他的什么方式,
threejs官方的导出json,好像也不能用,不知道为啥,是我哪里弄错了么

@akira-cn
Copy link
Contributor

threejs导出的为啥不能用啊?报什么错误呢?能否把数据贴出来我们看一下。

@xinde
Copy link
Author

xinde commented Jul 13, 2020

threejs导出的为啥不能用啊?报什么错误呢?能否把数据贴出来我们看一下。
嗯,抱歉没有描述清楚,稍后我上一个测试链接

@xinde
Copy link
Author

xinde commented Jul 13, 2020

@akira-cn
比如说我使用 https://threejs.org/editor/ 中的 examples 最后一个案例 shaders ,export object 的 json 如下:(好像因为导出的json 不是顶点数据)

{ "metadata": { "version": 4.5, "type": "Object", "generator": "Object3D.toJSON" }, "geometries": [ { "uuid": "EA781333-F3AE-470D-9110-A9724FCB42AA", "type": "IcosahedronBufferGeometry", "radius": 1, "detail": 4 }], "materials": [ { "uuid": "50ED51F1-DEA4-4B61-8082-BF41609E8C27", "type": "ShaderMaterial", "depthFunc": 3, "depthTest": true, "depthWrite": true, "stencilWrite": false, "stencilWriteMask": 255, "stencilFunc": 519, "stencilRef": 0, "stencilFuncMask": 255, "stencilFail": 7680, "stencilZFail": 7680, "stencilZPass": 7680, "wireframe": true, "uniforms": { "time": { "value": 0 } }, "vertexShader": "uniform float time;\nvarying vec3 vPosition;\nvoid main() {\n\tvPosition = position;\n\tvPosition.x += sin( time + vPosition.z * 4.0 ) / 4.0;\n\tvPosition.y += cos( time + vPosition.z * 4.0 ) / 4.0;\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( vPosition, 1.0 );\n}", "fragmentShader": "varying vec3 vPosition;\nvoid main() {\n\tgl_FragColor = vec4( vPosition * 2.0, 1.0 );\n}" }], "object": { "uuid": "FC7B6CF2-6386-4F47-9CE6-8ADB9FCA6E1F", "type": "Mesh", "name": "Icosahedron 1", "layers": 1, "matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1], "geometry": "EA781333-F3AE-470D-9110-A9724FCB42AA", "material": "50ED51F1-DEA4-4B61-8082-BF41609E8C27" } }

Uncaught (in promise) TypeError: Cannot read property 'data' of undefined
at ii.setGeometry (sprite-extend-3d.js:1)
at ii.remesh (sprite-extend-3d.js:1)
at sprite-extend-3d.js:1

@akira-cn
Copy link
Contributor

哦,这种是不支持的,只能支持简单的顶点数据。

obj转model,在这里有个简单的转换工具 https://github.com/spritejs/sprite-extend-3d/tree/master/tools

@xinde xinde closed this as completed Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants