Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pages/Javascript-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ Loads the specified scene by url and rebuilds the geometry. If no arguments are

`base_path` is an optional argument specifying an alternate base URL for resolving relative paths in the scene file. It is primarily useful for development and debugging.

#### `loadTextures()`
Reloads and rebinds all [textures](textures.md) in the scene.

#### `rebuild()`
Rebuilds the current scene from scratch.

Expand Down
31 changes: 29 additions & 2 deletions pages/textures.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ styles:
fox: [0, 32, 32, 32]
```

Whether defined in the `textures` element or inline, at a minimum, a URL must be passed:
Whether defined in the `textures` element or inline, at a minimum, a `URL` or `element` must be passed:

```yaml
textures:
Expand All @@ -76,7 +76,7 @@ If provided for a _lines_ style, the texture is repeated across the line, with t
## texture parameters

####`url`
Required _string_. Defines the path to an image file. No default.
Optional _string_, though either `url` or [`element`](#element) is required ([JS-only](https://github.com/tangrams/tangram). This element is required for [ES](https://github.com/tangrams/tangram-es)). Specifies the path to a texture source file. No default.

URLs can be absolute or relative.

Expand All @@ -90,6 +90,33 @@ URLs can be absolute or relative.
url: http://ghostimages.com/ghost.png
```

#### `element`
[[JS-only](https://github.com/tangrams/tangram)] Optional _string_, though either [`url`](#url) or `element` is required. Specifies a CSS element selector string. No default.

This parameter allows an HTML element to be used as the source of the texture, as identified by a CSS selector string.

For example, this canvas element:

`<canvas class='awesome-texture'>`

Can be referenced as:

```yaml
textures:
awesome-texture:
element: .awesome-texture
```

You can also reference an element by `id`, but the use of `#` in CSS means the YAML must be quoted so it's not interpreted as a YAML comment:

`<canvas id='texture-id'>`

```yaml
textures:
awesome-texture:
element: '#texture-id' # no comment!
```

#### `filtering`
Optional _string_, one of `linear`, `nearest`, or `mipmap`. Defaults to `linear`.

Expand Down