Relationship(param)

Relationship对象之间的关系。

new Relationship(param)

对象之间的关系。
Parameters:
Name Type Description
param object 初始参数。
Properties
Name Type Attributes Description
type string 关系类型。
name string 关系名称。
source THING.BaseObject | Array.<THING.BaseObject> | THING.Selector 关系源对象。
target THING.BaseObject | Array.<THING.BaseObject> | THING.Selector 关系目标对象。
queryDirection string <optional>
默认查询关系方向。
uuid string <optional>
关系UUID。
Example
let source = new THING.Object3D();
let target = new THING.Object3D();
let rel = new THING.Relationship({
     type: 'control',
     source: source,
     target: target
});

Members

name :string

获取/设置关系名称。
Example
let source = new THING.Object3D();
let target = new THING.Object3D();
let rel = new THING.Relationship({
     type: 'control',
		name: 'myRelationship',
     source: source,
     target: target
});
// @expect(rel.name == 'myRelationship')

queryDirection :RelationshipDirection

获取/设置关系查询方向。
Example
let source = new THING.Object3D();
let target = new THING.Object3D();
let rel = new THING.Relationship({
     type: 'control',
		name: 'myRelationship',
     source: source,
     target: target
});
// @expect(rel.queryDirection == THING.RelationshipDirection.OUT)

source :THING.BaseObject|Array.<THING.BaseObject>|THING.Selector

获取/设置关系源对象。
Example
let source = new THING.Object3D();
let target = new THING.Object3D();
let rel = new THING.Relationship({
     type: 'control',
		name: 'myRelationship',
     source: source,
     target: target
});
// @expect(rel.source == source)

target :THING.BaseObject|Array.<THING.BaseObject>|THING.Selector

获取/设置关系目标对象。
Example
let source = new THING.Object3D();
let target = new THING.Object3D();
let rel = new THING.Relationship({
     type: 'control',
		name: 'myRelationship',
     source: source,
     target: target
});
// @expect(rel.target == target)

type :string

获取/设置关系类型。
Example
let source = new THING.Object3D();
let target = new THING.Object3D();
let rel = new THING.Relationship({
     type: 'control',
     source: source,
     target: target
});
// @expect(rel.type == 'control')

Methods

destroy()

销毁关系。
Example
let source = new THING.Object3D()();
let target = new THING.Object3D()();
let rel = new THING.Relationship({
     type: 'control',
     source: source,
     target: target
});
rel.destroy()
// @expect(source.relationships.length == 0)