Cylindrical.clone()
方法返回一个新的 Cylindrical
对象,该对象是当前对象的副本。
Cylindrical
对象表示一个圆柱体坐标系,由半径、仰角和方位角三个属性构成。
使用 clone()
方法,我们可以快速复制一个 Cylindrical
对象,而无需重新输入属性值。
cylinder.clone()
返回一个新的 Cylindrical
对象,该对象是当前对象的副本。
const cylinder1 = new THREE.Cylindrical(1, Math.PI/2, Math.PI/4);
const cylinder2 = cylinder1.clone();
console.log(cylinder1.radius); //output: 1
console.log(cylinder1.theta); //output: 1.5707963267948966
console.log(cylinder1.y); //output: 0.7071067811865476
console.log(cylinder2.radius); //output: 1
console.log(cylinder2.theta); //output: 1.5707963267948966
console.log(cylinder2.y); //output: 0.7071067811865476
在本示例中,我们使用 new THREE.Cylindrical(1, Math.PI/2, Math.PI/4)
创建一个新的 Cylindrical
对象,该对象的半径为 1
,仰角为 π/2
,方位角为 π/4
。然后,我们使用 clone()
方法克隆了该对象,生成了一个新的 Cylindrical
对象 cylinder2
,并打印输出两个对象的属性值。可以看到 cylinder1
和 cylinder2
的属性值完全相同,说明 clone()
方法成功地复制了 cylinder1
对象。
Cylindrical.clone()
方法不会修改当前对象,而是返回一个新的克隆对象。因此,原始对象的属性值保持不变。