07.CSS2D渲染
import {OrbitControls} from "three/examples/jsm/controls/OrbitControls.js";
import {CSS2DRenderer,CSS2DObject} from "three/examples/jsm/renderers/CSS2DRenderer.js"
// 创建物体
const cube = new THREE.BoxGeometry(2,2,2);
const cubeMaterial = new THREE.MeshBasicMaterial({color:"#ff0000"})
const code = new THREE.Mesh(cube,cubeMaterial)
scene.add(code)
// 创建标签
const earthDic = document.createElement("div");
earthDic.className = "label";
earthDic.textContent = "文字内容"
const earthLabel = new CSS2DObject(earthDic);
earthLabel.position.set(0,1,0);
code.add(earthLabel)
// 实例化CSS2D渲染器
labelRenderer = new CSS2DRenderer();
labelRenderer.setSize( window.innerWidth, window.innerHeight );
labelRenderer.domElement.style.position = "fixed";
labelRenderer.domElement.style.left = "0px";
labelRenderer.domElement.style.top = "0px";
labelRenderer.domElement.style.color = "#ffffff";
// labelRenderer.domElement.style.pointerEvents = 'none';
threeContainer.appendChild(labelRenderer.domElement)
// 初始化轨道器,为CSS2D可以和模型同步移动,需要设置为labelRenderer渲染器
controls = new OrbitControls(camera,labelRenderer.domElement)
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇