如何将水从搅拌机导入到three.js。

huangapple go评论49阅读模式
英文:

How to get water from blender into three.js

问题

我使用Blender制作了透明的水,然后使用gltf导出,再用three.js导入,但水的属性不透明,就像一个蓝色的盒子一样。如何在three.js中导入透明的水?

import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'

const loader = new GLTFLoader()
loader.load(
  '../static/assets/model3.gltf',
  function (gltf) {
    console.log(gltf)
    const root = gltf.scene
    scene.add(root)
  },
  function (xhr) {
    console.log((xhr.loaded / xhr.total) * 100 + '% loaded')
  },
  function (error) {
    console.log('发生错误')
  }
)
const ambientLight = new THREE.AmbientLight(0xffffff, 1)
scene.add(ambientLight)
英文:

I made transparent water using Blender, exported it with gltf, and then imported it with three.js, so the water property is not transparent.
just like a blue box.

how can i import transparent water in three.js?

import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'

 const loader = new GLTFLoader()
  loader.load(
    '../static/assets/model3.gltf',
    function (gltf) {
      console.log(gltf)
      const root = gltf.scene
      scene.add(root)
    },
    function (xhr) {
      console.log((xhr.loaded / xhr.total) * 100 + '% loaded')
    },
    function (error) {
      console.log('An cerror occurred')
    }
  )
  const ambientLight = new THREE.AmbientLight(0xffffff, 1)
  scene.add(ambientLight)

答案1

得分: 0

大部分Blender的材质、修改器和动画样式都无法导出到任何格式。它们仅用于Blender内部渲染。如果您计划导出您的场景,我建议仔细阅读glTF插件文档。它解释了可以导出的材质和动画类型。

截至2023年,这通常意味着使用Principled BSDF材质,以及以下其中一种动画类型:蒙皮、形状目标和关键帧平移/旋转/缩放动画。也可以使用Principled BSDF制作类似水的体积折射效果,不过我不知道有关水的具体指南。

英文:

Most of Blender's materials, modifiers, and animation styles cannot be exported to any format. They exist only for rendering within Blender. If you're planning to export your scene, I'd recommend reviewing the glTF addon documentation very carefully. It explains the types of materials and animations that can be exported.

As of 2023, this generally means using Principled BSDF materials, and one of the following animation types: skinning, morph targets, and keyframe translation/rotation/scale animation. It's possible to make water-like volumetric refraction effects with Principled BSDF, as well, though I don't know of a guide for water specifically.

huangapple
  • 本文由 发表于 2023年6月26日 15:38:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76554507.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定