Skip to content

Commit

Permalink
feat: initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-viney committed Oct 19, 2024
0 parents commit 14ccdd6
Show file tree
Hide file tree
Showing 53 changed files with 9,183 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release

on:
push:
branches:
- main

jobs:
release:
name: Release
runs-on: ubuntu-24.04
environment: Publish to NPM
timeout-minutes: 10

steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18

- name: Checkout repository
uses: actions/checkout@v4

- name: Install packages
uses: bahmutov/npm-install@v1

- name: Wait for tests to complete
uses: lewagon/[email protected]
with:
ref: ${{ github.sha }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
check-regexp: Test

- name: Build demo app
run: npx vite build

- name: Deploy demo app to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: demo/dist

- name: Semantic release
uses: cycjimmy/semantic-release-action@v4
with:
dry_run: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Test

on:
push:
branches:
- main
pull_request:

jobs:
test:
name: Test
runs-on: ubuntu-24.04
timeout-minutes: 10

steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18

- name: Checkout repository
uses: actions/checkout@v4

- name: Install packages
uses: bahmutov/npm-install@v1

- name: Check code formatting
run: npm run format:check

- name: Run linters
run: npm run lint

- name: Run tests
run: npm run test
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.DS_Store
/*.tgz
dist
/node_modules
/npm-debug.log
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
}
13 changes: 13 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Run iesna demo",
"runtimeExecutable": "npm",
"runtimeArgs": ["run", "dev"],
"console": "integratedTerminal"
}
]
}
28 changes: 28 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"editor.rulers": [80],
"editor.tabSize": 2,

"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},

"files.exclude": {
"dist": true,
"node_modules": true
},

"[javascript]": {
"editor.formatOnSave": true
},
"[json]": {
"editor.formatOnSave": true
},
"[typescript]": {
"editor.formatOnSave": true
},
"[css]": {
"editor.formatOnSave": true
},
"javascript.preferences.importModuleSpecifier": "non-relative",
"typescript.preferences.importModuleSpecifier": "non-relative"
}
22 changes: 22 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# The MIT License (MIT)

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the “Software”), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<div align="center">
<img src="https://emoji2svg.deno.dev/api/💡" height="160px">
<h1>IESNA</h1>
<p>
<strong>
TypeScript library for parsing and rendering the
<br/>
IESNA LM-63 Photometric file format
</strong>
<br />
</p>

[<img src="https://img.shields.io/github/v/release/richard-viney/iesna">](https://github.com/richard-viney/iesna/releases/latest)
[<img src="https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release">](https://github.com/semantic-release/semantic-release)
[<img src="https://github.com/richard-viney/iesna/actions/workflows/test.yml/badge.svg">](https://github.com/richard-viney/iesna/actions/workflows/test.yml)
[<img src="https://img.shields.io/badge/License-MIT-blue.svg">](https://opensource.org/license/mit)
</div>

## About

This project is heavily based on the original publication "Parsing The IESNA
LM-63 Photometric Data File" and its accompanying source code, which can be
found [here](./vendor/iesna-c).

## Usage

To render an IES document to an HTML canvas using this library:

```ts
import * as IESNA from "iesna";

IESNA.renderToCanvas({
iesData: IESNA.parse("IES document goes here"),
canvas: document.getElementsByTagName("canvas")[0],
});
```

In addition to `IESNA.renderToCanvas()`, light sampling can be done using
`IESNA.sample()`. This function takes an IES data object and an x,y,z coordinate
in light space and returns the light intensity at that position.

```ts
const iesData = IESNA.parse("IES document goes here");
const intensity = IESNA.sample({ iesData, x, y, z });
```

## Demo

There is a demo of rendering IES documents in the browser available
[here](https://richard-viney.github.io/iesna).

To run it locally: `npm install && npm run dev`.
80 changes: 80 additions & 0 deletions demo/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
html {
--theme-bg-color-0: #24292e;
--theme-border-color-0: #3d4147;
--theme-text-color-default: #dddddd;
--theme-text-color-highlight: #ffffff;
}

body {
margin: 0;
overflow: hidden;
overscroll-behavior-x: none;

font-family: sans-serif;
font-size: 14px;

background-color: var(--theme-bg-color-0);
color: var(--theme-text-color-default);

display: grid;
grid-template-columns: auto 1fr;
grid-template-areas:
"header header"
"canvas document"
"controls document";
}

header {
grid-area: header;
display: flex;
gap: 1em;
align-items: center;
padding: 0.5em 1em;
margin-bottom: 2em;

border-bottom: 2px solid var(--theme-border-color-0);

a {
color: inherit;
transition: color 100ms;

&:hover {
color: var(--theme-text-color-highlight);
}
}
}

.controls {
padding: 0 2em;

grid-area: controls;
display: grid;
grid-template-columns: max-content auto;
grid-template-columns: max-content auto;
gap: 1.5em 4em;
align-items: center;
grid-template-areas:
"label0 control0"
"label1 control1"
"label2 control2"
"label3 control3";
}

.canvas-container {
grid-area: canvas;
padding: 0 2em 2em 2em;
}

canvas {
width: 420px;
height: 420px;

box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
border-radius: 4px;
}

textarea {
grid-area: document;
margin: 0 2em 2em 2em;
resize: none;
}
64 changes: 64 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<!doctype html>
<html>
<head>
<script
src="https://kit.fontawesome.com/4e8968f74f.js"
crossorigin="anonymous"
></script>

<link href="./index.css" rel="stylesheet" />
<script type="module" src="./index.ts"></script>
</head>

<body>
<header>
<img src="./logo.svg" height="48px" />
<h1>IESNA Demo</h1>
<a
href="https://github.com/richard-viney/iesna"
target="_blank"
style="margin-left: auto"
>
<i class="fa-github fa-brands fa-2x"></i>
</a>
</header>

<div class="canvas-container">
<canvas></canvas>
</div>

<div class="controls">
<label>IES Document</label>
<select id="light"></select>
<label>Distance</label>
<input
id="distance"
type="range"
min="0.001"
max="100"
value="0"
step="0.001"
/>
<label>Zoom</label>
<input
id="zoom"
type="range"
min="0.001"
max="5"
value="1.2"
step="0.001"
/>
<label>Brightness</label>
<input
id="brightness"
type="range"
min="0.001"
max="5"
value="1.2"
step="0.001"
/>
</div>

<textarea></textarea>
</body>
</html>
Loading

0 comments on commit 14ccdd6

Please sign in to comment.