in packages/layers/flyline/src/FlyLineLayer.ts [61:135]
init(projection, timeline, polaris) {
this.projection = projection
this.timeline = timeline
const listeningFlylineProps = [
'data',
'level',
'color',
'opacity',
'transparent',
'lineWidth',
'pointSize',
'texture',
'image',
'flipY',
'resolution',
'usePerspective',
'usePoint',
'infinity',
'lineSegments',
'flyPercent',
'pool',
'easing',
'frameDropping',
'useColors',
'colors',
] as const
this.listenProps(listeningFlylineProps, () => {
listeningFlylineProps.forEach((key) => {
// @note this is a problem of ts, key became a union type and props[key] collapsed into `never`
;(this.props[key] as any) = this.getProp(key)
})
const data = this.getProp('data')
if (!data || !data.length) return
this.props.pool = Math.max(data.length, this.getProp('pool') ?? 1)
// Re-create flyline instance
this.createFlyline(timeline, polaris)
this.updateFlylinesData(data)
})
this.listenProps(['renderOrder'], () => {
this.flyline && (this.flyline.mesh.renderOrder = this.getProp('renderOrder') ?? 0)
})
this.listenProps(['depthTest'], () => {
this.flyline && (this.flyline.mesh.material.depthTest = this.getProp('depthTest') ?? true)
})
this.listenProps(['duration', 'delay', 'repeat', 'minHeight', 'maxHeight', 'data'], () => {
this.props['duration'] = this.getProp('duration')
this.props['delay'] = this.getProp('delay')
this.props['repeat'] = this.getProp('repeat')
this.props['minHeight'] = this.getProp('minHeight')
this.props['maxHeight'] = this.getProp('maxHeight')
const data = this.getProp('data')
if (!data || !data.length) return
this.updateFlylinesData(this.getProp('data'))
})
this.onViewChange = (cameraProxy, polaris) => {
if (!this.flyline) return
const w = polaris.width
const h = polaris.height
const originRes = this.flyline.mesh.material.config['resolution']
if (originRes.x !== w || originRes.y !== h) {
this.flyline.mesh.material.config['resolution'] = {
x: w,
y: h,
}
}
}
}