效果
源码
import {
useEffect, useRef } from 'react'
import * as T from 'three'
import {
OrbitControls } from 'three/examples/jsm/controls/OrbitControls'
import {
DragControls } from 'three/examples/jsm/controls/DragControls'
import Stats from 'stats.js'
import {
GUI } from 'dat.gui'
const Demo15 = () => {
let stats, scene, camera, renderer, plane, planeGeometry, gui, controls, orbitControls
useEffect(() => {
init()
}, [])
const ThreeContainer = useRef()
const initGui = () => {
controls = {
addBox,
removeBox,
numberOfObjects: scene.children.length,
rotationSpeed: 0.01,
}
gui = new GUI()
gui.add(controls, 'addBox')
gui.add(controls, 'removeBox')
gui.add(controls, 'numberOfObjects').listen()
gui.add(controls, 'rotationSpeed', 0, 0.1)
}
const initStats = () => {
stats = new Stats()
stats.