cesiumlab / cesiumlab/XbsjEarthUI

我试了两种加obj的方法,想问下有什么区别

Open
#37 0 comments 0 reactions 0 assignees View on GitHub
documentation question
Dominant language
JavaScript
Stars
734
Forks
193
PR merge metrics
No merged PRs in 30d

Description

再问下,我试了两种加obj的方法,想问下有什么区别。

1.用XE.Obj.Type(earth, config)生成出来的东西并没有加入sceneTree

var config = {
"czmObject": {
xbsjType: "Cylinder", // 类型不可更改!
startPosition, // 起点
endPosition, // 终点
radius: 20, // 圆柱体的实际半径
fixScreenSize, // 固定的屏幕像素,如果为0的话,表示用实际尺寸,即radius;大于0时radius不起作用
maxSceneScale, // 使用固定的屏幕像素时,模型实际的最大缩放比例,如果设置为Number.POSITIVE_INFINITY表示没有限制
// maxSceneScale: Number.POSITIVE_INFINITY, // 无限大
},
ref: name
};
console.log(config)

const cylinder = new XE.Obj.Cylinder(this._earth, config);
console.log(earth.sceneTree.$refs[name])

我这样可以把cylinder加到地图上,但无法通过earth.sceneTree.$refs[name]索引。

2. 通过这种方法把obj加进去:
earth.sceneTree.root.children.push(config)
var cylinder = earth.sceneTree.$refs[name].czmObject
这样在scenetree里可以索引加进去的cylinder。
我想问下,这两种方法除了第二种把obj加进了scenetree外还有什么区别呢?第二种有没有什么其他副作用呢?谢谢

---

第二种方式,相当于对象受sceneTree管理;直接清空数组,就会自动销毁;
第一种方式,需要手动调用destroy方法来销毁对象;
第一种方式创建的对象,也可以加到sceneTree当中,通过 scene.root.children.push(new XE.SceneTree.Leaf(obj))加入即可,加入之后,就不能手动destroy了。

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the two creation paths shown in issue #37: new XE.Obj.Cylinder(this._earth, config) and earth.sceneTree.root.children.push(config). Compare how each path affects earth.sceneTree.$refs[name] and cleanup, using the stated destroy and Leaf behavior as the completion criteria. No file or test is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.