From ce526d303aba820a8add02b59c880fefafdfe64e Mon Sep 17 00:00:00 2001 From: Peter Richardson Date: Tue, 14 Jun 2016 16:54:38 -0400 Subject: [PATCH] texture param and loadTexture() --- pages/Javascript-API.md | 3 +++ pages/textures.md | 31 +++++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/pages/Javascript-API.md b/pages/Javascript-API.md index 966c065..cb5052c 100644 --- a/pages/Javascript-API.md +++ b/pages/Javascript-API.md @@ -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. diff --git a/pages/textures.md b/pages/textures.md index d0def13..162a37b 100644 --- a/pages/textures.md +++ b/pages/textures.md @@ -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: @@ -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. @@ -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: + +`` + +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: + +`` + +```yaml +textures: + awesome-texture: + element: '#texture-id' # no comment! +``` + #### `filtering` Optional _string_, one of `linear`, `nearest`, or `mipmap`. Defaults to `linear`.