如何在网页中呈现搅拌机模型? [英] How to render a Blender Model in a web page?

查看:0
本文介绍了如何在网页中呈现搅拌机模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经研究了在我的Web应用程序中渲染我的搅拌机模型的多个选项,现在我正在将我的模型导出为.gltf格式,下面是我的代码

App.js

import React, { Suspense } from 'react';
import './App.css';
import Model from './Model'
function App() {
  return (
    <div className="App">
      <Suspense fallback={null}>
        <Model />
      </Suspense>
    </div>
  );
}

export default App;

Model.js

import React from 'react'
import { useLoader } from 'react-three-fiber'
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'
import Scene from './scene.gltf'
function Model(props) {
  const { nodes, materials } = useLoader(GLTFLoader, Scene)
  return (
    <div>

    </div>
  )
}

export default Model

问题

GLTF加载器引发错误

我想要的

  • 我希望将我的模型在Reaction应用程序的搅拌器中显示为 尽我所能
  • 旋转控制很棒..

抛出错误

RangeError: Invalid typed array length: 1299
    at new Float32Array (<anonymous>)
    at GLTFLoader.js:1965
    at async Promise.all (:3000/index 0)
    at async Promise.all (:3000/index 0)
    at async Promise.all (:3000/index 4)
    at async Promise.all (:3000/index 0)
    at async Promise.all (:3000/index 2)
    at async Promise.all (:3000/index 0)
    at async Promise.all

推荐答案

它不是这样工作的。R3f是一种Reaction渲染器。REACTION-DOM渲染div和跨度,r3f渲染网格和材质。您可以很好地混合这两个呈现器,但不能将div转储到r3f,或将网格转储到反应域。

https://codesandbox.io/s/r3f-contact-shadow-c75jh

这篇关于如何在网页中呈现搅拌机模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆