Class: AssetKeepr

AssetKeepr()

new AssetKeepr()

Assets Manager

Note it's spelled "keepr", not "keeper".

Source:

Members

(static, constant) assets

Static assets buffer for global resource management

Source:

assets

Properties:
Name Type Description
assets object

get global assets map

Source:

canvs

Properties:
Name Type Description
canvs THREE.Container

get container canvas

Source:

dynatex

Properties:
Name Type Description
dynatex number

get dynamic canvas texture

Source:

log

Properties:
Name Type Description
log number

get log level

Source:

Methods

(static) defaultex() → {THREE.Texture}

Get a spark texture, in 'data:image/png;base64'.

Source:
Returns:
Type
THREE.Texture

(static) drawText(cmp, fillStyleopt, contextFontopt) → {THREE.CanvasTextrue}

draw text - synchrodous

v0.3.21 change log: try scaling plane to adapt more or less words than paras defined canvas can hold, via only scaling texture;

Test: test/html/dynatex.html

see docs/Dynamic Text

Reference: // https://threejsfundamentals.org/threejs/lessons/threejs-textures.html // https://threejsfundamentals.org/threejs/lessons/threejs-canvas-textures.html

Parameters:
Name Type Attributes Description
cmp Dynatex

options

Properties
Name Type Description
text string

the text to display

xywh object

see docs/Dynamic Text

fillStyle string <optional>

the fillStyle to clear with, if not provided, fallback on .clearRect

contextFont string <optional>

the font to use

Source:
Returns:
Type
THREE.CanvasTextrue

(static) geoHexaprism(featrues, options) → {array}

Load hexatile from points in 3857 - not geojson, but json data are supposed the as same format of geojson, except coordinates' values.

Parameters:
Name Type Description
featrues array.<GeoFeature>
options object
Source:
Returns:

a 3d array of a fake cell vertices

Type
array

(static) geoHexaprismAsync(url, options, onload, onErroropt) → {array}

Load hexatile from points in 3857 - not geojson, but json data are supposed the as same format of geojson, except coordinates' values.

Parameters:
Name Type Attributes Description
url url
options object
onload function

callback on assets loaded. arguments: BufferGeometry, each vertices has 'position', 'a_h', 'a_tan', 'uv' & 'normal' attributes

onError function <optional>

callback on oboe failed.

Source:
Returns:

a 3d array of a fake cell vertices

Type
array

(static) geojsonPaths(url, options, onLoad, onErroropt) → {array}

Load path of 3857 - not geojson, but json data are supposed the same format, except coordinates' values.

Parameters:
Name Type Attributes Description
url url
options object
onLoad function

callback on assets loaded.

onError function <optional>

callback on oboe failed.

Source:
Returns:

a 3d array of a fake path: [[[0, 0], [1, 0]]]

Type
array

(static) geoTexturePrism(featrues, options) → {array}

Load hexatile from points in 3857 - not geojson, but json data are supposed the as same format of geojson, except coordinates' values. This should only used for real buildings with textures. For vitual buildings, use @AssetKeepr.geoPrismBoxes

Parameters:
Name Type Description
featrues array.<GeoFeature>
options object
Source:
Returns:

a 3d array of a fake cell vertices

Type
array

(static) init(x)

Initialize

Parameters:
Name Type Description
x object

singleton

Source:

(static) loadCanvtex(cmpCanv, stamp, onUpdate) → {Canvas}

Initialize a Canvas component with a THREE.CanvasTexture from canvas, which is not initialized when return.

The component will be updated when it's ready

DESIGN-MEMO

  1. This function maintance dirty with tick flag. Referenced canvase won't been updated if the component's stamp less than the asset's stamp
  2. Texture canvas are sharable.

Reference

https://stackoverflow.com/questions/3768565/drawing-an-svg-file-on-a-html5-canvas
https://jsfiddle.net/Wijmo5/h2L3gw88/
https://bl.ocks.org/mbostock/1276463
threejs example: https://threejs.org/examples/?q=canvas#webgl_materials_texture_canvas
example source: https://github.com/mrdoob/three.js/blob/master/examples/webgl_materials_texture_canvas.html
threejs doc CanvasTexture: https://threejs.org/docs/index.html#api/en/textures/CanvasTexture

Parameters:
Name Type Description
cmpCanv Canvas

Canvas component

stamp number

optional, if stamp is less than x.lastUpdate, ignore the request; if undefined, always update. So set this carefully for performance optimization - updating canvas is a heavy work load.

onUpdate function

optional, callback when html canvas texture updated. parameter: canvas {HTML.Canvas}, texture {THREE.CanvasTexture}

Source:
Returns:

the Canvas component referencing object:
where
tex: THREE.CanvasTexture when html canvas is initialized. But before this is undefined.
canvas: HTML canvas when html canvas is initialized. But before this is undefined.
ctx2d: HTML canvas 2d context when html canvas is initialized.
But before this its is undefined - can not been used for sampling before onUpdate called.

Type
Canvas

(static) loadGltf(sceneopt, obj3opt, url, onload)

load gltf model
If obj3 is provided, then after loaded, set the scene transform according to obj3.transfrom, set obj3.mesh = gltf.scene.
For details, see reference: GLTF format from x-visual docs.
Also see Three.js example - GLTFLoader and Three.js tuturial of gltf loader

Parameters:
Name Type Attributes Description
scene THREE.Scene <optional>

if provided, add the loaded gltf.scene to it.

obj3 Obj3 <optional>

[in out] after loaded, set the scene transform according to obj3.transfrom, set obj3.mesh = gltf.scene

url stirng

A string containing the path/URL of the .gltf or .glb file.

onload function

callback on assets loaded.
If not provided, load entire gltf scene as child of main scene (the argument)

Source:

(static) loadGltfNodes(obj3, url, nnames, onParsed)

Parameters:
Name Type Description
obj3 Obj3
url string
nnames array.<string>
onParsed function
Source:

(static) loadSVG(url, opts, onload)

Load svg - don't use this to load pathes

Parameters:
Name Type Description
url string

string

opts object

opts.withMesh: bool - convert fill to mesh ( z = 0 )
opts.withStroke: bool - convert stroke to polygon ( z = 0 )
{drawFillShapes: bool, wireframe: THREE.material.wireframe, stroke: bool}

onload function

function(group: THREE.Group)

Source: