Everything in a world is a part. A part is the language's one unit of organization, as a module is in Cone: a named place that holds whatever belongs there. It may hold child parts, fields, materials, functions, triggers, layouts, images, sounds and files such as a JPEG. What a part holds decides what it is. A part with a frame (and usually a shape) stands somewhere in the world: the lantern, the cottage, the land. A part without a frame is a container: materials, which holds the world's materials, or a design not itself placed. The parts nest into one tree, and a part's place in that tree, written as a path, is its name, its identity and the line along which it is owned.

What a part is

A part is not a type and not an object in Cone's sense. It is closest to a folder that can also stand in the world. Four facts follow from that:

How you write it

A part is declared with part and its name, then optionally : what, then optionally named options separated by commas. Its contents (fields, child parts, rules and calls) are indented under it. A line may continue after a trailing comma, indented past the word part.

part cottage, at: (-16, land.height((-16, 0, 330)), 330)   // a one-off, placed on the land
  part porch
    part wallLantern1: wallLantern, at: (-0.7, 2.4, 0)
    part wallLantern2: wallLantern, at: (0.85, 2.4, 0)

part materials                              // a part with no frame: a holder
  part lanternGlass: ...
  part lanternBulb  : ...

The wall lanterns' places are in the porch's frame, which is in the cottage's. Each material is itself a part holding a material, under the frameless holder materials; a drawn part names one with material: materials.lanternGlass (materials.html). Two places are two parts: a figure's eyes are part leftEye: ..., at: body.bone(leftEye) and part rightEye: ....

Part options

The options follow the colon and the what, in this order when several are given. Each has a default, so each is named.

OptionType and defaultMeaning
material:material (a material part, materials.lanternGlass)the material a drawn part is made of
at:a place, or an attachment such as around(camera, rotation: world), body.bone(head), nearest(course, to: ear); default the parent's originwhere the part is, in its parent's frame (frames.html)
rotation:rotation = noRotationhow the part is turned: rotation: rotation(0.3 rad), rotation: rotation(a, about: axis), or a rotation value
scale:number or (x, y, z) = 1the part's size relative to its parent: one number for every axis, or a tuple of three for x, y and z in turn
unscaled:bool = falsetrue: the part's meters are true meters again, whatever the scale above it (Frames)
castsShadow:bool = truewhether the part throws shadows
home:a placethe place the part is brought back to (Frames: a part's home)
clearance:meters = 0 mthe room the part needs: a scatter keeps clear of it (Generators: what a scatter means). The amphora's is clearance: 1.2 m, the balloon's 12 m
detailBySize:list of pixel sizesthe apparent sizes at which coarser builds of the part take over, stated as a requirement: detailBySize: [240 px, 80 px] draws the part from its second build under 240 px across the screen and its third under 80 px (Construction: detail by size)
visibleUpTo:, fadeFrom:meters; fractionhow far the part must be drawn, and the share of that distance (from its far end back) over which it fades out: visibleUpTo: 140 m, fadeFrom: 0.7 keeps it whole to 98 m and fades it out by 140 m. The engine may draw it farther, never nearer
lives:client | server | bothwhere the part exists (Distribution)

A part of a particular kind takes options of its own, in the same place. A land, which draws its own ground, takes material: like any drawn part and also edge: (what lies past the border of its grid) and fineOver: (where its ground is drawn finest): part land, at: (0, 0, 0), material: shaded(terrain), edge: sea(wade: 0.6 m) (Terrain).

Every drawn part also has a field tint, a color whose default is white, which a derive or a set may write: derive(glass.tint, gain) (Materials: the tint). It multiplies a painted material's colors too, and its components may pass 1. A tree's age tint is its part's tint, and its leaves' registration takes the part's.

  part glass: panes(size),    material: materials.lanternGlass, at: hangsAt
  part bulb : filament(size), material: materials.lanternBulb,  at: hangsAt, castsShadow: false
  if let Some(p) = panel {
    part solar: scale(p, by: size), material: panelIn, at: hangsAt
  }
  part light: pointLight(color: color(1, 0.14, 0.01), source: 2 cm, reach: 5 m, castsShadow: true),
              at: hangsAt + (0, 0.335 m * size, 0)

The balloon, with a turned and scaled envelope and a basket scaled with it, its platform and area written in the envelope's units (meterUnit is a meter in those units, 1/9):

  part envelope: balloonEnvelope(), material: paints.envelopePaint,
                 at: (0, -bottom, 0), rotation: rotation(0.3 rad), scale: 9
    part basket: scale(wickerBasket(), by: meterUnit), material: paints.wicker
      platform(self, floor: floorTop * meterUnit, standOn: box(x: -inside * meterUnit ..= inside * meterUnit, z: -inside * meterUnit ..= outside * meterUnit),
               walls: (wallTop - floorTop) * meterUnit, on: [left, right, back])
      area(self, box(x: -inside * meterUnit ..= inside * meterUnit, y: (floorTop - 0.1 m) * meterUnit ..= (floorTop + 1.9 m) * meterUnit,
                     z: -inside * meterUnit ..= outside * meterUnit))

Engine registrations are calls in the part's body that name the part. What a part is handed to an engine as (an area that senses, a platform to stand on, a body that moves, a being that can be possessed) is written as a call in the part's body whose first argument is the part, as body(self, ...), solid(self, ...) and seat(frame, ...) already are. The calls are body, solid, area, platform, seat and being; the others that fit a part to another one are written the same way: fittedTo(self, body), skinnedTo(self, body), under(self, trousers), grownOn(self, body.head), foliage(self, X, material: m). foliage registers the tree's leaves, drawn in the material m; trees that name the same material share it, and its tint is the part's tint.

area(p: part, volume: shape)
platform(p: part, floor: meters, standOn: shape, walls: meters = 0 m, on: List[side] = [])
being(p: part, possessable: bool = false, targetable: bool = true)
part post: stake(), material: materials.lanternBlack
  area(self, sphere(radius: 4 m, at: (0, 0.2, 0)))        // the area round the post

part villager: people.averageWoman                      // a design reached by a path
  being(self, possessable: true)                          // a visitor may take this body

Names and paths

A path names a part by the chain of its ancestors, joined by dots, the same dot that reaches a field:

island.cottage.porch.rockingChair
pathLanterns.lantern[12].glass

The path separator / is also Cone's division sign: i / 20 divides, army.troll[0] is a path. This is listed under Open questions.

Folders and files

What it means

A path is a chain of frames

A part's position, rotation and size are stated relative to its parent and composed down the path. An office placed 10 m aft in a spaceship stays there: when the ship flies and turns, the office moves and turns with it, and nothing in the office's description changes. A frameless part's children are placed relative to the nearest ancestor that has a frame, the world at the top; under the hypothesis of scenes, the chain stops at the part's scene, since each scene has its own coordinate system (Worlds, scenes and regions). The kinds of frame are on frames.html.

A path carries ownership

What happens to a part happens to everything under it: removing it, showing or hiding it, putting it to sleep as a region, drawing its distant form in place of its parts. Removing the boss removes the army it holds; hiding the cottage hides its porch and wall lanterns. A simpler version of one mesh drawn further away (per-mesh level of detail) stays the engine's choice; what a whole hierarchy looks like from far away is the designer's intent, stated as content (Construction: distant forms).

Any part can be a region

A region is not a kind of part. Any part can be one: a part whose contents may be absent from a visitor's machine, with a stand-in drawn while they are. Regions nest: a city, a district in it, a house's interior in that. They wake when they might be seen (Worlds, scenes and regions).

A path is identity, not location

When a rider stands in the balloon's basket, being carried is execution state: the engine moves the rider with the basket, but the rider's path does not change. In the same way a door swung open has a current placement different from its defined one. Who owns a part's current place, the content or an engine, is on frames.html.

The world is the top part

The world itself is the root of the tree. World state (the lamp level, which weather is in force) is the root's fields; world settings (how long the day is) are its fixed fields; world rules (the lamps' dusk fade, the spells) are its events. There is no separate kind of "world script". Under the hypothesis of scenes, the world's children are its scenes, and the world itself holds what they share: its rules, state that survives moving between scenes, and what a visitor carries from one to another (Worlds: the world above its scenes).

Shared things are parts held somewhere

A material used by many parts is not a special "shared definition". Its type is material; sharing is only several parts referring to one instance, as several references point at one struct. The instance has identity and may have changing fields: one bulb material, its glow derived once, can light every lantern of two types. It lives wherever it is held (the world's root, a design, one lantern), lasts as long as its holder, and anyone refers to it by path. The materials / root is a convention of arrangement, not of meaning.

The tree may grow and shrink while the world runs

A part's set of children may change as the world runs: a wall hit by paint gains splats, a boss gains an army. That set is state of the parent, living on the client, the server or both like any other field. The rest follows from rules already stated: the new part's name is a numbered path under the parent, its frame and ownership are the parent's, and its lifetime is a handler or an animator's end (actions.html, spawn and remove).

A part's children are drawn only while it is. A child is present when its parent is, and gone when its parent is gone: a flock of birds that is a child of a sky is not drawn where that sky is not (the labyrinth, a scene with no sky), and a lantern's glass goes with the lantern. This is the lifetime-by-holder rule applied to what is drawn, and needs no line of content.

Two namespaces

A world's own names are paths in its tree. Beside them are the vocabulary names the browser supplies: lathe, pointLight, dusk, npcbehave.patrol. A world never names a package to import; the browser finds vocabulary names where they are used. Shape tools are written bare (lathe, box, loftAlong), never with their package's name (Appendix: shape tools). A world's own name is found first (above), so a world should not give its own parts or shapes the tools' names. A local name hides a tool of the same name. A world's own shape face, or a part glass, is what face and glass mean where it is in scope. The tool is still reached through its package: sculpt.face is the tool, whatever the world has called its own.

What a part cannot do

How it connects

Open questions

← Text and structured text | Contents | Fields →